public async Task TestThat_GetCoffeeShopLocations_When_DataReaderReturnsItems_Returns_NotNullLocationList() { // Arrange var dataReaderMock = new Mock <ICoffeeShopLocationDataReader>(); dataReaderMock .Setup(x => x.ReadCoffeeShopLocations()) .ReturnsAsync(MockObjects.ValidCoffeeShopLocations); var coffeeShopLocationRepository = new CoffeeShopLocationRepository(dataReaderMock.Object); // Act var locations = await coffeeShopLocationRepository.GetCoffeeShopLocations(); // Assert Assert.NotNull(locations); }
public async Task TestThat_GetCoffeeShopLocations_When_DataReaderReturnsItems_Returns_ExpectedNumberOfElements() { // Arrange var dataReaderMock = new Mock <ICoffeeShopLocationDataReader>(); dataReaderMock .Setup(x => x.ReadCoffeeShopLocations()) .ReturnsAsync(MockObjects.ValidCoffeeShopLocations); var coffeeShopLocationRepository = new CoffeeShopLocationRepository(dataReaderMock.Object); // Act var locations = await coffeeShopLocationRepository.GetCoffeeShopLocations(); // Assert Assert.Equal(5, locations.Count()); }
public async Task TestThat_GetCoffeeShopLocations_When_DataReaderThrowsDataProviderException_Throws_DataProviderExceptionWithExpectedMessage() { // Arrange var dataReaderMock = new Mock <ICoffeeShopLocationDataReader>(); dataReaderMock .Setup(x => x.ReadCoffeeShopLocations()) .Throws(new DataProviderException(MockValues.CsvDataProviderExceptionMessage)); var coffeeShopLocationRepository = new CoffeeShopLocationRepository(dataReaderMock.Object); // Act async Task Act() => await coffeeShopLocationRepository.GetCoffeeShopLocations(); // Assert var exception = await Assert.ThrowsAsync <DataProviderException>(Act); Assert.Equal(MockValues.CsvDataProviderExceptionMessage, exception.Message); }