public void HashCombiner_Test_Folder() { using var combiner1 = new HashGenerator(); using var combiner2 = new HashGenerator(); using var combiner3 = new HashGenerator(); DirectoryInfo dir = PrepareFolder(); var file1Path = Path.Combine(dir.FullName, "hastest1.txt"); File.Delete(file1Path); using (StreamWriter file1 = File.CreateText(Path.Combine(dir.FullName, "hastest1.txt"))) { file1.WriteLine("hello"); } // first test the whole folder combiner1.AddFolder(dir); combiner2.AddFolder(dir); Assert.AreEqual(combiner1.GenerateHash(), combiner2.GenerateHash()); // now add a file to the folder var file2Path = Path.Combine(dir.FullName, "hastest2.txt"); File.Delete(file2Path); using (StreamWriter file2 = File.CreateText(Path.Combine(dir.FullName, "hastest2.txt"))) { // even though files are the same, the dates are different file2.WriteLine("hello"); } combiner3.AddFolder(dir); Assert.AreNotEqual(combiner1.GenerateHash(), combiner3.GenerateHash()); }