Beispiel #1
0
        public void Create_WithExistingIngredient_DoesNotThrowAndEqualsCreated()
        {
            //Arrange
            var model = new RecipeDetailModel
            {
                Name        = "Recipe 2",
                Description = "Testing recipe 2",
                Duration    = TimeSpan.FromHours(2),
                FoodType    = FoodType.Dessert,
                Ingredients =
                {
                    new IngredientAmountDetailModel
                    {
                        IngredientName        = "Ingredient 1",
                        IngredientDescription = "Testing Ingredient",
                    },
                    IngredientAmountMapper.MapDetailModel(CookBookSeedingDbContext.IngredientAmountEntity1)
                }
            };

            //Act
            var returnedModel = RepositorySUT.InsertOrUpdate(model);


            //Assert
            Assert.NotEqual(Guid.Empty, returnedModel.Id);
            Assert.NotEqual(Guid.Empty, returnedModel.Ingredients.First().Id);
            FixIds(returnedModel, model);

            Assert.Equal(model, returnedModel, RecipeDetailModel.RecipeDetailModelComparer);
        }
        public void Create_WithExistingAndNotExistingIngredient_DoesNotThrowAndEqualsCreated()
        {
            //Arrange
            RecipeDetailModel model = new RecipeDetailModel
            {
                Name        = "Recipe 2",
                Description = "Testing recipe 2",
                Duration    = TimeSpan.FromHours(2),
                FoodType    = FoodType.Dessert,
                Ingredients =
                {
                    new IngredientAmountDetailModel
                    {
                        IngredientName        = "Ingredient 1",
                        IngredientDescription = "Testing Ingredient",
                    },
                    IngredientAmountMapper.MapEntityToDetailModel(DAL.Seeds.IngredientAmountSeeds.IngredientAmountEntity1)
                }
            };

            //Act
            RecipeDetailModel returnedModel = _repositorySUT.InsertOrUpdate(model);


            //Assert
            Assert.NotEqual(Guid.Empty, returnedModel.Id);
            Assert.NotEqual(Guid.Empty, returnedModel.Ingredients.First().Id);
            FixIds(returnedModel, model);

            Assert.Equal(model, returnedModel);
        }