public static async Task IsSubsetOf(string expectedPath, string actualPath) { var expectedFiles = DirectoryPathIterator.GetChildPathsRecursive(expectedPath); var actualFiles = DirectoryPathIterator.GetChildPathsRecursive(actualPath); CollectionAssert.IsSubsetOf(expectedFiles.ToArray(), actualFiles.ToArray()); foreach (var file in expectedFiles) { var expectedFileContents = await Sha256.GetFileHashAsync(Path.Combine(expectedPath, file)); var actualFileContents = await Sha256.GetFileHashAsync(Path.Combine(actualPath, file)); Assert.AreEqual(expectedFileContents, actualFileContents, "file " + file + " is different"); } }
private async Task ApplyPatchWithInstructions(IEnumerable <FilePatchInstruction> instructions) { var instructionsJson = JsonConvert.SerializeObject(instructions); var instructionsFilename = Path.Combine(_patchDir.Path, "instructions.json"); File.WriteAllText(instructionsFilename, instructionsJson); try { await _directoryPatcher.ApplyPatchAsync(TestProgressHandlerFactory.Create(), new CancellationToken(), await Sha256.GetFileHashAsync(instructionsFilename)); } finally { File.Delete(instructionsFilename); } }