public async Task DotNetCoreProjectTemplateUsingBackslashesInPrimaryOutputPathsIsSupported() { var templatingService = new TemplatingService(); string templateId = "MonoDevelop.Ide.Tests.TwoProjects.CSharp"; string scanPath = Util.GetSampleProjectPath("DotNetCoreTemplating"); var template = MicrosoftTemplateEngineProjectTemplatingProvider.CreateTemplate(templateId, scanPath); string tempDirectory = Util.CreateTmpDir("BackslashInPrimaryOutputTest"); string projectDirectory = Path.Combine(tempDirectory, "BackslashInPrimaryOutputTestProject"); Directory.CreateDirectory(projectDirectory); string library1FileToOpen = Path.Combine(projectDirectory, "Library1", "MyClass.cs"); string library2FileToOpen = Path.Combine(projectDirectory, "Library2", "MyClass.cs"); var result = await templatingService.ProcessTemplate(template, new NewProjectConfiguration() { CreateSolution = true, Location = tempDirectory, SolutionName = "BackslashInPrimaryOutputTest", ProjectName = "BackslashInPrimaryOutputTestProject", CreateProjectDirectoryInsideSolutionDirectory = false, }, null); solution = result.WorkspaceItems.OfType <Solution> ().Single(); await solution.SaveAsync(Util.GetMonitor()); Assert.AreEqual(2, solution.GetAllProjects().Count()); Assert.IsNotNull(solution.FindProjectByName("Library1")); Assert.IsNotNull(solution.FindProjectByName("Library2")); Assert.AreEqual(2, result.Actions.Count()); Assert.That(result.Actions, Contains.Item(library1FileToOpen)); Assert.That(result.Actions, Contains.Item(library2FileToOpen)); }
public async Task DotNetCoreProjectTemplate_ExcludeFile(string exclude) { var templatingService = new TemplatingService(); string templateId = "MonoDevelop.Ide.Tests.FileFormatExclude.CSharp"; string scanPath = Util.GetSampleProjectPath("FileFormatExclude"); var xmlFilePath = Path.Combine(scanPath, "test.xml"); string expectedXml = "<root><child/></root>"; File.WriteAllText(xmlFilePath, expectedXml); var template = MicrosoftTemplateEngineProjectTemplatingProvider.CreateTemplate(templateId, scanPath) as MicrosoftTemplateEngineSolutionTemplate; template.FileFormattingExclude = exclude; string tempDirectory = Util.CreateTmpDir("FileFormatExcludeTest"); string projectDirectory = Path.Combine(tempDirectory, "FileFormatExcludeTestProject"); Directory.CreateDirectory(projectDirectory); var result = await templatingService.ProcessTemplate(template, new NewProjectConfiguration() { CreateSolution = true, Location = tempDirectory, SolutionName = "FileFormatExcludeTest", ProjectName = "FileFormatExcludeTestProject", CreateProjectDirectoryInsideSolutionDirectory = false, }, null); solution = result.WorkspaceItems.OfType <Solution> ().Single(); await solution.SaveAsync(Util.GetMonitor()); xmlFilePath = Path.Combine(projectDirectory, "test.xml"); string xml = File.ReadAllText(xmlFilePath); if (string.IsNullOrEmpty(exclude)) { // Ensure formatting occurs if file is not excluded. Assert.AreNotEqual(expectedXml, xml); } else { Assert.AreEqual(expectedXml, xml); } }