public bool Equals(string left, string right) { var leftHash = fileHashService.CalculateHash(left); var rightHash = fileHashService.CalculateHash(right); return(leftHash.SequenceEqual(rightHash)); }
public void ShouldCalculateHashViaInnerService() { var filePath = "foo.txt"; var hash = new byte[] { 0x00 }; fileHashService.CalculateHash(filePath).Returns(hash); var calculatedHash = service.CalculateHash(filePath); calculatedHash.ShouldBe(hash); }
public void ShouldGetHash() { var filePath = CreateFile("foo.txt"); var hash = fileHashService.CalculateHash(filePath); var expectation = new byte[] { 0xB1, 0x0A, 0x8D, 0xB1, 0x64, 0xE0, 0x75, 0x41, 0x05, 0xB7, 0xA9, 0x9B, 0xE7, 0x2E, 0x3F, 0xE5 }; hash.ShouldBe(expectation); }
/// <inheritdoc /> public byte[] CalculateHash(string path) { if (hashCache.TryGetValue(path, out var hash)) { return(hash); } var calculatedHash = fileHashService.CalculateHash(path); hashCache.Add(path, calculatedHash); return(calculatedHash); }
public void ShouldVerifyCandidates() { var firstFilePath = "foo.txt"; var secondFilePath = "bar.txt"; var hash = new byte[] { 0x00, 0x00, 0x00, 0x00 }; fileHashService.CalculateHash(firstFilePath).Returns(hash); fileHashService.CalculateHash(secondFilePath).Returns(hash); var candidates = Substitute.For <IDuplicateFile>(); candidates.FilePaths.Returns(new List <string> { firstFilePath, secondFilePath }); var files = service.VerifyCandidates(new List <IDuplicateFile> { candidates }).ToList(); files.Count.ShouldBe(1); files.Single().FilePaths.ShouldContain(firstFilePath); files.Single().FilePaths.ShouldContain(secondFilePath); }