public async Task WhenListingsRepoThrowsExceptionThensExceptionIsBubbledUp() { _mockListingRepository.Setup(x => x.GetListingsAsync(It.IsAny <GetListingsRequest>())) .ThrowsAsync(new Exception("some ex")); var mapper = GetMockMapper(); var service = new GetListingsService(_mockListingRepository.Object, mapper, _logger); var exception = await Assert.ThrowsAsync <Exception>(() => service.ExecuteAsync(new Models.GetListingsRequest { Suburb = "southbank" })); Assert.Equal("some ex", exception.Message); }
public async Task WhenListingsExistInRepoOrCacheThenReturnsCorrectNoOfItemsAndCount() { _mockListingRepository.Setup(x => x.GetListingsAsync(It.IsAny <GetListingsRequest>())) .ReturnsAsync(GetDummyListings()); var mapper = GetMockMapper(); var service = new GetListingsService(_mockListingRepository.Object, mapper, _logger); var result = await service.ExecuteAsync(new Models.GetListingsRequest { Suburb = "southbank" }); Assert.Equal(5, result.Items.Count()); Assert.Equal(5, result.Total); }