Exemplo n.º 1
0
        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");
            }
        }
Exemplo n.º 2
0
        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);
            }
        }