public async Task GetAllAsync_ShouldReturnIEnumerableCountryDTOAsync() { //Arrange var options = InMemory.GetOptions("GetAllAsync_ShouldReturnIEnumerableCountryDTOAsync"); using (var context = new BOContext(options)) { var country = new Country() { Name = "Bulgaria" }; context.Countries.Add(country); await context.SaveChangesAsync(); } using (var context = new BOContext(options)) { //Act var sut = new CountriesService(context); var result = await sut.GetAllAsync(); //Assert Assert.IsInstanceOfType(result, typeof(IEnumerable <CountryDTO>)); } }
public async Task GetAllAsync_ShouldReturnCorrectResult() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var countriesRepository = new EfDeletableEntityRepository <Country>(context); var countriesService = new CountriesService(countriesRepository); var seeder = new DbContextTestsSeeder(); await seeder.SeedCountriesAsync(context); var countries = await countriesService.GetAllAsync <CountriesServiceAllModel>(); var count = countries.ToList().Count; Assert.True(count == 8, ErrorMessage); }
public async Task GetAllAsync_ShouldReturnEmptyIfNoCountriesAsync() { //Arrange var options = InMemory.GetOptions("GetAllAsync_ShouldReturnEmptyIfNoCountriesAsync"); using (var context = new BOContext(options)) { } using (var context = new BOContext(options)) { //Act var sut = new CountriesService(context); var result = await sut.GetAllAsync(); //Assert Assert.AreEqual(result.Count(), 0); } }
public async Task GetAllAsync_ShouldReturnNullIfModelHasNoNameFailsAsync() { //Arrange var options = InMemory.GetOptions("GetAllAsync_ShouldReturnNullIfModelHasNoNameFailsAsync"); using (var context = new BOContext(options)) { var country = new Country(); context.Countries.Add(country); await context.SaveChangesAsync(); } using (var context = new BOContext(options)) { //Act var sut = new CountriesService(context); var result = await sut.GetAllAsync(); //Assert Assert.AreEqual(result, null); } }