示例#1
0
        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));
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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());
        }
示例#5
0
        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);
        }
示例#6
0
        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);
            });
        }