public void WhenGettingCountryListAndRepositoryThrows_ThenWrapsException() { var countryRepositoryMock = new Mock<ICountryRepository>(); countryRepositoryMock.Setup(c => c.GetAll()).Throws<InvalidOperationException>(); var services = new CountryServices(countryRepositoryMock.Object); var ex = Assert.Throws<BusinessServicesException>(() => services.GetCountriesAndRegionsList()); Assert.IsType<InvalidOperationException>(ex.InnerException); }
public void WhenGettingCountryListAndRepositoryReturnsNoRecords_ThenReturnsEmptyCollection() { var countryRepositoryMock = new Mock<ICountryRepository>(); countryRepositoryMock.Setup(c => c.GetAll()).Returns(new List<Country>()); var services = new CountryServices(countryRepositoryMock.Object); var countries = services.GetCountriesAndRegionsList(); Assert.Empty(countries); }
public void WhenGettingCountryList_ThenReturnsCountryNames() { var countryRepositoryMock = new Mock<ICountryRepository>(); countryRepositoryMock.Setup(c => c.GetAll()).Returns(new List<Country>() {new Country()}); var services = new CountryServices(countryRepositoryMock.Object); var countries = services.GetCountriesAndRegionsList(); Assert.NotNull(countries); Assert.Equal(1, countries.Count); }