private void TestTargetFileDatesInvariant() { var files = DirectoryPathIterator.GetChildPathsRecursive(_targetDir.Path).ToArray(); var offenders = files.Where(x => new FileInfo(Path.Combine(_targetDir.Path, x)).LastWriteTimeUtc != _dummyLastWriteTime); CollectionAssert.AreEquivalent(new string[] { }, offenders.ToArray()); }
public void TestEmpty() { using (var directory = new TemporaryDirectory()) { var filePaths = DirectoryPathIterator.GetChildPathsRecursive(directory.Path); CollectionAssert.AreEquivalent(new string[] { }, filePaths.ToArray()); } }
public void TestFlat() { using (var directory = new TemporaryDirectory()) { File.WriteAllText(Path.Combine(directory.Path, "a"), ""); File.WriteAllText(Path.Combine(directory.Path, "b"), ""); File.WriteAllText(Path.Combine(directory.Path, "c"), ""); var filePaths = DirectoryPathIterator.GetChildPathsRecursive(directory.Path); CollectionAssert.AreEquivalent(new string[] { "a", "b", "c" }, filePaths.ToArray()); } }
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"); } }