public TransientTestFile CreateFile(TransientTestFolder transientTestFolder, string fileName, string contents = "") { var file = WithTransientTestState(new TransientTestFile(transientTestFolder.FolderPath, Path.GetFileNameWithoutExtension(fileName), Path.GetExtension(fileName))); File.WriteAllText(file.Path, contents); return(file); }
public TransientTestProjectWithFiles(string projectContents, string[] files, string relativePathFromRootToProject = ".") { _folder = new TransientTestFolder(); var projectDir = Path.Combine(TestRoot, relativePathFromRootToProject); Directory.CreateDirectory(projectDir); ProjectFile = Path.Combine(projectDir, "build.proj"); File.WriteAllText(ProjectFile, FileUtilities.CleanupFileContents(projectContents)); CreatedFiles = FileUtilities.CreateFilesInDirectory(TestRoot, files); }
public void EmptyGlobalJson() { using (var testEnvironment = TestEnvironment.Create()) { TransientTestFolder folder = testEnvironment.CreateFolder(); try { File.WriteAllText(Path.Combine(folder.FolderPath, GlobalJsonReader.GlobalJsonFileName), @" { } "); var context = new MockSdkResolverContext(Path.Combine(folder.FolderPath, "foo.proj")); GlobalJsonReader.GetMSBuildSdkVersions(context).Should().BeNull(); } finally { folder.Revert(); } } }
/// <summary> /// Create a temp file name under a specific temporary folder. The file is expected to exist when the test completes. /// </summary> /// <param name="transientTestFolder">Temp folder</param> /// <param name="extension">Extension of the file (defaults to '.tmp')</param> /// <returns></returns> public TransientTestFile ExpectFile(TransientTestFolder transientTestFolder, string extension = ".tmp") { return(WithTransientTestState(new TransientTestFile(transientTestFolder.FolderPath, extension, createFile: false, expectedAsOutput: true))); }