public async Task InsertScannedLocationAsync_IgnoresDuplicateScannedLocation() { // ARRANGE var files = new Mock <IDataCache <ScannedFile> >(); var locations = new Mock <IDataCache <ScannedLocation> >(); FileHashService service = new FileHashService(files.Object, locations.Object); locations.Setup(t => t.ListData()) .Returns(() => { List <ScannedLocation> scannedLocations = new List <ScannedLocation>() { new ScannedLocation() { Path = "bar" } }; return(scannedLocations.AsQueryable()); }); // ACT await service.InsertScannedLocationAsync(new ScannedLocation() { Path = "bar" }); // ASSERT locations.Verify(t => t.InsertData(It.IsAny <ScannedLocation>()), Times.Never()); }
public async Task InsertScannedLocationAsync_InsertsScannedLocation() { // ARRANGE var files = new Mock <IDataCache <ScannedFile> >(); var locations = new Mock <IDataCache <ScannedLocation> >(); FileHashService service = new FileHashService(files.Object, locations.Object); // ACT await service.InsertScannedLocationAsync(new ScannedLocation() { Path = "bar" }); // ASSERT locations.Verify(t => t.InsertData(It.IsAny <ScannedLocation>()), Times.Once()); }