Reporter | Sergey Kuks (coox) |
---|---|
Created | Jun 2, 2011 6:01:03 PM |
Updated | Apr 13, 2018 5:44:08 PM |
Resolved | Apr 13, 2018 5:44:08 PM |
Subsystem | Quick Fixes |
Assignee | Alisa Afonina (alisa.afonina) |
Priority | Normal |
State | Obsolete |
Type | Unspecified |
Fix version | Backlog |
Affected versions | No Affected versions |
Fixed In Version ReSharper | Undefined |
VsVersion | All Versions |
over mySetProjectFileProperties
protected sealed class TestSolutionConfiguration
{
private readonly TestProjectConfiguration[] myProjectsConfigurations;
private readonly string mySolutionFileName;
public TestSolutionConfiguration(string solutionFileName, params TestProjectConfiguration[] projectConfigurations)
{
mySolutionFileName = solutionFileName;
myProjectsConfigurations = projectConfigurations;
}
public ISolution CreateSolution(ISolutionManager solutionManager)
{
var solutionFilePath = new FileSystemPath(mySolutionFileName); // Don't pass in illegal paths
var testSolution = (SolutionImpl)solutionManager.OpenNewSolution(solutionFilePath);
try
{
using (new ProjectModelBatchChangeCookie(solutionManager, testSolution, SimpleTaskExecutor.Instance))
{
var nameToProject = myProjectsConfigurations
.Select(projectConfig => projectConfig.CreateProject(solutionManager, testSolution, mySetProjectFileProperties))
.ToDictionary(project => project.Name);
foreach (var projectConfig in myProjectsConfigurations)
{
var project = nameToProject[projectConfig.ProjectName];
foreach (var projectName in projectConfig.ProjectNamesToRefer)
{
if (!nameToProject.ContainsKey(projectName))
{
Assert.Fail("Could not find project '{0}'", projectName);
}
((ProjectImpl)project).DoAddReference(new SimpleProjectToProjectReference(project, nameToProject[projectName]));
}
}
}
}
catch
{
solutionManager.CloseSolution(testSolution);
throw;
}
return testSolution;
}
public string SolutionFilePath
{
get { return mySolutionFileName; }
}
public TestProjectConfiguration[] ProjectsConfigurations
{
get { return myProjectsConfigurations; }
}
public bool MatchesSolution(ISolution solution)
{
if (solution.SolutionFilePath != new FileSystemPath(mySolutionFileName))
return false;
if (solution.GetAllProjects().Count != myProjectsConfigurations.Length + 2 /* Misc & SolutionProject */)
return false;
foreach (var projectConfiguration in myProjectsConfigurations)
{
var project = solution.GetProject(projectConfiguration.ProjectName);
if (project == null)
return false;
if (!projectConfiguration.MatchesProject(project))
return false;
}
return true;
}
public void RefillSolution(ISolutionManager solutionManager, ISolution solution)
{
foreach (var projectConfiguration in myProjectsConfigurations)
{
var project = solution.GetProject(projectConfiguration.ProjectName);
Assert.IsNotNull(project, "project == null");
projectConfiguration.RefillProject(solutionManager, solution, project);
}
}
}