public void DeleteRecipeTest()
        {
            // Arrange
            IDataAccessObjectFactory factory  = DatabaseFactory.GetInstance();
            IDataAccessObject        database = factory.GetDao();

            database.AddRecipe(new RecipeDto()
            {
                Name   = "Test",
                Amount = 0,
                PreparationDescription = "Preparation test",
                PreparationTime        = TimeSpan.FromMinutes(30),
                SkillLevel             = "Skill level test"
            });

            // Act
            database.DeleteRecipe("Test");

            // Assert
            List <RecipeSimplifiedDto> list = database.GetRecipeList();

            foreach (RecipeSimplifiedDto r in list)
            {
                if (r.Name == "Test")
                {
                    Assert.Fail();
                }
            }
        }
        public void AddRecipeTest()
        {
            // Arrange
            IDataAccessObjectFactory factory  = DatabaseFactory.GetInstance();
            IDataAccessObject        database = factory.GetDao();
            RecipeDto newRecipe = new RecipeDto()
            {
                Amount = 2,
                Name   = "Test",
                PreparationDescription = "DescriptionTest",
                PreparationTime        = new TimeSpan(0, 20, 0),
                SkillLevel             = "Begginer",
                Ingredients            = new List <IngredientDto>()
                {
                    new IngredientDto()
                    {
                        Amount = 2, IngredientName = "IngredientTest", Unit = "UnitTest"
                    },
                    new IngredientDto()
                    {
                        Amount = 2, IngredientName = "IngredientTest2", Unit = "UnitTest"
                    }
                },
                Picture = ImageConverter.ImagetoByteArray(@"C:\Users\Bartek\Downloads\zupa-pomidorowa.jpg")
            };

            // Act
            database.AddRecipe(newRecipe);

            // Assert
            List <RecipeSimplifiedDto> list = database.GetRecipeList();

            foreach (RecipeSimplifiedDto r in list)
            {
                if (r.Name == "Test")
                {
                    // Cleanup and pass
                    database.DeleteRecipe("Test");
                    Assert.Pass();
                }
            }

            Debug.WriteLine("Check connection: " + factory.GetConnectionString());
            Assert.Fail();
        }
Beispiel #3
0
        public void AddRecipe(RecipeDto recipe)
        {
            IDataAccessObject dao = daoFactory.GetDao();

            dao.AddRecipe(recipe.adaptee);
        }