public void ReturnCorrectBeer_When_ParamsValid() { var options = Utils.GetOptions(nameof(ReturnCorrectBeer_When_ParamsValid)); var beertype = TestsModelsSeeder.SeedBeerType(); var brewery = TestsModelsSeeder.SeedBrewery(); var beerDTO = TestsModelsSeeder.SeedBeerDTO(); using (var arrangeContext = new BeerOverflowContext(options)) { arrangeContext.BeerTypes.Add(beertype); arrangeContext.Breweries.Add(brewery); arrangeContext.SaveChanges(); } using (var assertContext = new BeerOverflowContext(options)) { var sut = new BeerServices(assertContext); var act = sut.CreateBeer(beerDTO); var result = assertContext.Beers.FirstOrDefault(beer => beer.Name == beerDTO.Name); Assert.AreEqual(beerDTO.Id, result.Id); Assert.AreEqual(beerDTO.Name, result.Name); Assert.AreEqual(beerDTO.AlcoholByVolume, result.AlcoholByVolume); Assert.AreEqual(beerDTO.Brewery, result.Brewery.Name); } }
public void ThrowArgumentException_When_BeerAlreadyExists() { var options = Utils.GetOptions(nameof(ThrowArgumentException_When_BeerAlreadyExists)); var beerDTO = TestsModelsSeeder.SeedBeerDTO(); var beer = TestsModelsSeeder.SeedBeer(); using (var arrangeContext = new BeerOverflowContext(options)) { arrangeContext.Beers.Add(beer); arrangeContext.SaveChanges(); } using (var assertContext = new BeerOverflowContext(options)) { var sut = new BeerServices(assertContext); } }