Reporter | Sergey Coox (coox) |
---|---|
Created | Jun 2, 2011 6:01:03 PM |
Updated | Mar 27, 2012 5:03:10 PM |
Priority | Critical |
Type | Unspecified |
Fix versions | 7.0 |
State | Open |
Assignee | Alexey Kuptsov (alexey.kuptsov) |
Subsystem | No subsystem |
Affected versions | No Affected versions |
Fixed in build | No Fixed in build |
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); } } }