public async Task ScrapAsync_EventsAlreadyExistInRepository_RemoveAllOldEventsFromRepositoryAddNewOnes(int eventsCount, EventCategories category) { var scrappedEvents = generateEvents(eventsCount); _scrapperMock.Setup(scr => scr.Scrap(category)).ReturnsAsync(scrappedEvents); var eventsMock = scrappedEvents.AsQueryable().BuildMock(); _eventRepositoryMock.Setup(rp => rp.Get()).Returns(eventsMock.Object); var todaysEvents = new List <EventDate>(); var todaysEventsMock = todaysEvents.AsQueryable().BuildMock(); _eventDateRepositoryMock.Setup(rp => rp.Get()).Returns(todaysEventsMock.Object); var serviceMock = new ScrapperServiceMock(_scrapperMock.Object, _eventRepositoryMock.Object, _eventDateRepositoryMock.Object); await serviceMock.ScrapAsync(category); foreach (var scrappedEvent in scrappedEvents) { _eventRepositoryMock.Verify(sr => sr.RemoveAsync(scrappedEvent.Id), Times.Once); } }
public async Task ScrapAsync_EventRepositoryAddRangeCalledOnce(EventCategories category) { var serviceMock = new ScrapperServiceMock(_scrapperMock.Object, _eventRepositoryMock.Object, _eventDateRepositoryMock.Object); await serviceMock.ScrapAsync(category); _eventRepositoryMock.Verify(sr => sr.AddRangeAsync(It.IsAny <IEnumerable <Event> >()), Times.Once); }
public async Task ScrapAsync_KinoAfishaScrapperScrapCalledOnce(EventCategories category) { var serviceMock = new ScrapperServiceMock(_scrapperMock.Object, _eventRepositoryMock.Object, _eventDateRepositoryMock.Object); await serviceMock.ScrapAsync(category); _scrapperMock.Verify(sr => sr.Scrap(category), Times.Once); }
public async Task ScrapAsync_ScrapperReturnedEvents_AddedToRepository(int eventsCount, EventCategories category) { var scrappedEvents = generateEvents(eventsCount); _scrapperMock.Setup(scr => scr.Scrap(category)).ReturnsAsync(scrappedEvents); var eventsEmpty = new List <Event>(); var eventsMock = eventsEmpty.AsQueryable().BuildMock(); _eventRepositoryMock.Setup(rp => rp.Get()).Returns(eventsMock.Object); var serviceMock = new ScrapperServiceMock(_scrapperMock.Object, _eventRepositoryMock.Object, _eventDateRepositoryMock.Object); await serviceMock.ScrapAsync(category); _eventRepositoryMock.Verify(sr => sr.AddRangeAsync(scrappedEvents), Times.Once); }