public void Test_Comparison_Fails_For_Different_Files() { // This test just checks the file size comparer, not the matching algorithm var mockIo = Substitute.For <IIO>(); var comparer = new FileSizeComparer(); comparer.Init(mockIo); var fileA = "a.file"; var fileB = "different.foo"; Assert.That(comparer.WantsToHandle(fileA), Is.True); Assert.That(comparer.WantsToHandle(fileB), Is.True); // Setup the io to return different sizes mockIo.ReadFile(fileA).Returns(MakeStreamFromString("a")); mockIo.ReadFile(fileB).Returns(MakeStreamFromString("different")); Assert.That(() => comparer.Handle(fileA, fileB), Throws.Exception); }
public void Test_Comparison_Is_Valid_For_Same_File_Sizes() { // This test expects the files to be of equal length and must not fail var mockIo = Substitute.For <IIO>(); var comparer = new FileSizeComparer(); comparer.Init(mockIo); var fileA = "a.file"; var fileB = "different.foo"; Assert.That(comparer.WantsToHandle(fileA), Is.True); Assert.That(comparer.WantsToHandle(fileB), Is.True); // Mock the io to check for file size only mockIo.ReadFile(fileA).Returns(MakeStreamFromString("123")); mockIo.ReadFile(fileB).Returns(MakeStreamFromString("abc")); Assert.That(() => comparer.Handle(fileA, fileB), Throws.Nothing); }