diff options
Diffstat (limited to 'main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs')
-rw-r--r-- | main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs index 16ef3155f6..60aac3a4a0 100644 --- a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs +++ b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs @@ -79,10 +79,17 @@ namespace MonoDevelop.Projects // Ensure the project is buildable var result = await sol.Build (Util.GetMonitor (), "Debug"); Assert.AreEqual (0, result.ErrorCount, "#1"); + } + + [Test] + public async Task BuildConsoleProjectAfterRename () + { + Solution sol = TestProjectsChecks.CreateConsoleSolution ("console-project-msbuild"); + await sol.SaveAsync (Util.GetMonitor ()); // Ensure the project is still buildable with xbuild after a rename ProjectOptionsDialog.RenameItem (sol.GetAllProjects ().First (), "Test"); - result = await sol.Build (Util.GetMonitor (), "Release"); + var result = await sol.Build (Util.GetMonitor (), "Release"); Assert.AreEqual (0, result.ErrorCount, "#2"); } @@ -117,6 +124,7 @@ namespace MonoDevelop.Projects Solution sol = TestProjectsChecks.CreateConsoleSolution ("console-project-msbuild"); sol.ConvertToFormat (MSBuildFileFormat.VS2010); Project p = sol.Items [0] as Project; + await p.WriteProjectAsync (Util.GetMonitor ()); p.ProjectProperties.SetValue ("TestProperty", "TestValue"); await sol.SaveAsync (Util.GetMonitor ()); @@ -212,12 +220,12 @@ namespace MonoDevelop.Projects Assert.IsNotNull (p.Configurations ["Debug|x86"]); Assert.IsNotNull (p.Configurations ["Debug|x86-64"]); - Assert.IsNotNull (p.Configurations ["Debug|Other"]); - Assert.IsNotNull (p.Configurations ["Release|x86"]); Assert.IsNotNull (p.Configurations ["Release|x86-64"]); Assert.IsNotNull (p.Configurations ["Release|Other"]); - + Assert.IsNotNull (p.Configurations ["Test|More"]); + Assert.AreEqual (6, p.Configurations.Count); + string originalContent = File.ReadAllText (p.FileName); await p.SaveAsync (Util.GetMonitor ()); @@ -1173,8 +1181,7 @@ namespace MonoDevelop.Projects savedXml = File.ReadAllText (projFile); Assert.AreEqual (refXml, savedXml); - c = p.Configurations.FirstOrDefault<SolutionItemConfiguration> (co => co.Id == "Debug"); - p.Configurations.Remove (c); + p.Configurations.RemoveRange (p.Configurations.Where<SolutionItemConfiguration> (co => co.Name == "Debug")); await p.SaveAsync (Util.GetMonitor ()); @@ -1250,8 +1257,10 @@ namespace MonoDevelop.Projects var p = (Project) sol.Items [0]; var conf = p.Configurations.OfType<ProjectConfiguration> ().FirstOrDefault (c => c.Name == "Debug"); - conf.Name = "Test"; - conf.IntermediateOutputDirectory = p.BaseDirectory.Combine ("obj","Test"); + var newConf = p.CreateConfiguration ("Test"); + newConf.CopyFrom (conf); + p.Configurations [p.Configurations.IndexOf (conf)] = newConf; + newConf.IntermediateOutputDirectory = p.BaseDirectory.Combine ("obj","Test"); await p.SaveAsync (Util.GetMonitor ()); @@ -1473,6 +1482,50 @@ namespace MonoDevelop.Projects Assert.AreEqual (sol.ItemDirectory.ToString (), p.MSBuildProject.EvaluatedProperties.GetValue ("SolutionDir")); } + [Test] + public async Task RenameConfiguration () + { + // When renaming a configuration, paths that use the configuration name should also be renamed + + string solFile = Util.GetSampleProject ("console-project", "ConsoleProject.sln"); + Solution sol = (Solution) await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile); + + var p = (DotNetProject) sol.Items [0]; + var c = p.GetConfiguration (new ItemConfigurationSelector ("Release")); + var renamed = p.CreateConfiguration ("Test"); + renamed.CopyFrom (c, true); + p.Configurations.Remove (c); + p.Configurations.Add (renamed); + await p.SaveAsync (Util.GetMonitor ()); + + var savedXml = File.ReadAllText (p.FileName); + var compXml = Util.ToSystemEndings (File.ReadAllText (p.FileName.ChangeName ("ConsoleProject-conf-renamed"))); + Assert.AreEqual (compXml, savedXml); + } + + [Test] + public async Task ProjectWithDuplicateConfigGroup () + { + // The project has two property groups with Debug|AnyCPU. This has to result in a single + // Debug configuration. If a change is done in the configuration, it has to be applied + // to the last group. + + string projFile = Util.GetSampleProject ("msbuild-tests", "project-with-duplicated-conf.csproj"); + var p = (Project)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile); + + Assert.AreEqual (2, p.Configurations.Count); + + var c = p.GetConfiguration (new ItemConfigurationSelector ("Debug")) as DotNetProjectConfiguration; + Assert.IsNotNull (c); + Assert.IsTrue (c.DebugSymbols); + + c.Properties.SetValue ("Test","foo"); + await p.SaveAsync (Util.GetMonitor ()); + + var savedXml = File.ReadAllText (p.FileName); + var refXml = File.ReadAllText (p.FileName.ChangeName ("project-with-duplicated-conf-saved")); + Assert.AreEqual (refXml, savedXml); + } } class MyProjectTypeNode: ProjectTypeNode |