public async Task AddAsycTest() { //Arrange InPortDbContext context = InPortContextFactory.Create(); UnitOfWorkContainer unitwork = new UnitOfWorkContainer(context); ICountryRepository countryRepository = unitwork.Repository.CountryRepository; Guid countryId = new Guid("A3C82D06-6A07-41FB-B7EA-903EC456BFC5"); Country country2 = new Country("Colombia", "CO"); country2.ChangeCurrentIdentity(countryId); //Act await countryRepository.AddAsync(country2); await unitwork.SaveChangesAsync(); Country country = await countryRepository.SingleAsync(e => e.Id == countryId); //Assert country.ShouldNotBeNull(); country.CountryName.ShouldBe("Colombia"); country.CountryISOCode.ShouldBe("CO"); country.Id.ShouldBe(countryId); }
public async Task AddRangeAsycTest() { //Arrange InPortDbContext context = InPortContextFactory.Create(); UnitOfWorkContainer unitwork = new UnitOfWorkContainer(context); ICountryRepository countryRepository = unitwork.Repository.CountryRepository; Guid countryId1 = new Guid("A3C82D06-6A07-41FB-B7EA-903EC456BFC5"); Country country1 = new Country("Colombia", "CO"); country1.ChangeCurrentIdentity(countryId1); Guid countryId2 = new Guid("B3C82D06-6A07-41FB-B7EA-903EC456BFC5"); Country country2 = new Country("Venezuela", "VZ"); country2.ChangeCurrentIdentity(countryId2); List <Country> list = new List <Country>() { country1, country2 }; //Act await countryRepository.AddAsync(list); await unitwork.SaveChangesAsync(); Country countryF1 = await countryRepository.SingleAsync(e => e.Id == countryId1); Country countryF2 = await countryRepository.SingleAsync(e => e.Id == countryId2); //Assert countryF1.ShouldNotBeNull(); countryF1.CountryName.ShouldBe("Colombia"); countryF1.CountryISOCode.ShouldBe("CO"); countryF1.Id.ShouldBe(countryId1); countryF2.ShouldNotBeNull(); countryF2.CountryName.ShouldBe("Venezuela"); countryF2.CountryISOCode.ShouldBe("VZ"); countryF2.Id.ShouldBe(countryId2); }