public void AddProject(ProjectCreator creator, string path) { string normalizedPath = TestRepoUtils.NormalizePath(path); string targetFileName = Path.Combine(TestRepoRoot, normalizedPath); creator.Save(targetFileName); }
public static string GetTestInputPath(string relativeTestInputPath) { return(Path.Combine( Path.GetDirectoryName(typeof(TestRepoBuilder).Assembly.Location), "inputs", TestRepoUtils.NormalizePath(relativeTestInputPath))); }
private async Task AddFileWithContents(string path, string contents) { string normalizedPath = TestRepoUtils.NormalizePath(path); string targetFileName = Path.Combine(TestRepoRoot, normalizedPath); Directory.CreateDirectory(Path.GetDirectoryName(targetFileName)); using (StreamWriter writer = new StreamWriter(targetFileName)) { await writer.WriteAsync(contents); } }
private void CloneFileFromTestResources(string file) { string normalizedPath = TestRepoUtils.NormalizePath(file); string inputsFileName = GetTestInputPath(normalizedPath); string targetFileName = Path.Combine(TestRepoRoot, normalizedPath); if (!File.Exists(inputsFileName)) { throw new ArgumentException($"{file} doesn't exist at {inputsFileName}"); } Directory.CreateDirectory(Path.GetDirectoryName(targetFileName)); File.Copy(inputsFileName, targetFileName); }
private void CloneSubdirectoryFromTestResources(string path) { string normalizedPath = TestRepoUtils.NormalizePath(path); string resourcesPath = GetTestInputPath(normalizedPath); string testPath = Path.Combine(TestRepoRoot, normalizedPath); if (!Directory.Exists(resourcesPath)) { throw new ArgumentException($"{resourcesPath} is not a file or a directory that exists in the test resources"); } var allFiles = Directory.GetFiles(resourcesPath, "*.*", SearchOption.AllDirectories); foreach (var file in allFiles) { string targetFileName = file.Replace(resourcesPath, testPath); Directory.CreateDirectory(Path.GetDirectoryName(targetFileName)); File.Copy(file, targetFileName); } }