public async Task NewSharedProjectAddedToExistingSolutionUsesCorrectBuildAction() { solution = TestProjectsChecks.CreateConsoleSolution("shared-project"); await solution.SaveAsync(Util.GetMonitor()); var template = ProjectTemplate.ProjectTemplates.FirstOrDefault(t => t.Id == "MonoDevelop.CSharp.SharedProject"); var dir = Util.CreateTmpDir(template.Id); var cinfo = new ProjectCreateInformation { ProjectBasePath = dir, ProjectName = "ProjectName", SolutionName = "SolutionName", SolutionPath = dir }; var sharedAssetsProject = template.CreateProjects(solution.RootFolder, cinfo) .OfType <SharedAssetsProject> ().Single(); var myclassFile = sharedAssetsProject.Files.First(f => f.FilePath.FileName == "MyClass.cs"); Assert.AreEqual("Compile", myclassFile.BuildAction); }
public async Task NewSharedProjectAddedToExistingSolutionUsesCorrectBuildAction() { solution = TestProjectsChecks.CreateConsoleSolution("shared-project"); await solution.SaveAsync(Util.GetMonitor()); var template = ProjectTemplate.ProjectTemplates.FirstOrDefault(t => t.Id == "MonoDevelop.CSharp.SharedProject"); var dir = Util.CreateTmpDir(template.Id); var cinfo = new ProjectCreateInformation { ProjectBasePath = dir, ProjectName = "ProjectName", SolutionName = "SolutionName", SolutionPath = dir }; var sharedAssetsProject = template.CreateProjects(solution.RootFolder, cinfo) .OfType <SharedAssetsProject> ().Single(); // Template initialization is now asynchronous so we need to wait and unblock the UI thread // to ensure the template finishes adding files to the project. const int timeout = 2000; // ms int waitedTime = 0; int delayTime = 100; ProjectFile myclassFile = null; while (myclassFile == null) { myclassFile = sharedAssetsProject.Files.FirstOrDefault(f => f.FilePath.FileName == "MyClass.cs"); if (myclassFile == null) { if (waitedTime >= timeout) { Assert.Fail("Timed out waiting for file to be added to shared project."); } await Task.Run(async() => await Task.Delay(delayTime)); waitedTime += delayTime; } } ; Assert.AreEqual("Compile", myclassFile.BuildAction); }