public async Task SaveAsync_InsertsPieInTheDatabase() { var pie = Pie.Create("Apple pie", "Awesome apple pie", new Portions(8, 10)); var savedPie = await _pieRepository.SaveAsync(pie); Assert.NotNull(savedPie); Assert.NotNull(_databaseFixture.DbContext.Pies.SingleOrDefault(x => x.Id == pie.Id)); }
public void Create_ReturnsAValidPie() { var pie = Pie.Create("Apple pie", "Awesome apple pie with chunks", new Portions(8, 10)); Assert.NotNull(pie); Assert.Equal("Apple pie", pie.Name); Assert.Equal("Awesome apple pie with chunks", pie.Description); Assert.Equal(new Portions(8, 10), pie.Portions); }
public async Task FindById_ReturnsExistingPies() { var expectedPie = Pie.Create("Apple pie", "Awesome apple pie", new Portions(8, 10)); await _pieRepository.SaveAsync(expectedPie); var actualPie = await _pieRepository.FindByIdAsync(expectedPie.Id); Assert.NotNull(actualPie); }
public async Task FindAllAsync_ReturnsAllPies() { await _pieRepository.SaveAsync(Pie.Create("Apple pie", "Awesome apple pie", new Portions(8, 10))); await _pieRepository.SaveAsync(Pie.Create("Cherry pie", "Awesome cherry pie", new Portions(8, 10))); await _pieRepository.SaveAsync(Pie.Create("Blackforest pie", "Some pie from germany, pretty delicious", new Portions(8, 10))); var pies = await _pieRepository.FindAllAsync(0); Assert.NotNull(pies); Assert.Equal(3, pies.Count()); }
public void UpdateIngredients_StoresTheIngredients() { var pie = Pie.Create("Apple pie", "Awesome apple pie with chunks", new Portions(8, 10)); var ingredients = new[] { new Ingredient("Apples", false, 0.6), new Ingredient("Sugar", false, 0.2), new Ingredient("Flour", true, 0.1), new Ingredient("Cinnamon", false, 0.05), new Ingredient("Salt", false, 0.05), }; pie.UpdateIngredients(ingredients); Assert.NotEmpty(pie.Ingredients); }
public void UpdateIngredients_ThrowsForTooLowRelativeAmounts() { var pie = Pie.Create("Apple pie", "Awesome apple pie with chunks", new Portions(8, 10)); var ingredients = new[] { new Ingredient("Apples", false, 0.4), new Ingredient("Sugar", false, 0.2), new Ingredient("Flour", true, 0.1), new Ingredient("Cinnamon", false, 0.05), new Ingredient("Salt", false, 0.1), }; Assert.Throws <ArgumentException>(() => { pie.UpdateIngredients(ingredients); }); }