public async Task InsertScannedFileAsync_IgnoresDuplicateFile() { // ARRANGE var files = new Mock <IDataCache <ScannedFile> >(); var locations = new Mock <IDataCache <ScannedLocation> >(); var mockScannedFile = new ScannedFile() { Name = "foo", Path = "bar", Hash = new byte[32] }; FileHashService service = new FileHashService(files.Object, locations.Object); files.Setup(t => t.ListData()).Returns(() => new List <ScannedFile>() { new ScannedFile() { Name = "foo", Path = "bar", Hash = new byte[32] } }.AsQueryable()); // ACT await service.InsertScannedFileAsync(mockScannedFile); // ASSERT files.Verify(t => t.InsertData(It.IsAny <ScannedFile>()), Times.Never()); }
public async Task InsertScannedFileAsync_InsertsScannedFile() { // ARRANGE var files = new Mock <IDataCache <ScannedFile> >(); var locations = new Mock <IDataCache <ScannedLocation> >(); FileHashService service = new FileHashService(files.Object, locations.Object); files.Setup(t => t.ListData()).Returns(() => new List <ScannedFile>().AsQueryable()); // ACT await service.InsertScannedFileAsync(new ScannedFile() { Name = "foo", Path = "bar" }); // ASSERT files.Verify(t => t.InsertData(It.IsAny <ScannedFile>()), Times.Once()); }