コード例 #1
0
        public void GetAll_DatabaseEmptyAtFirst_ZeroOutput()
        {
            //Arrange, Act
            int result = Recipe.GetAll().Count;

            //Assert
            Assert.Equal(0, result);
        }
コード例 #2
0
        public void Recipe_Delete_RemoveObjectFromDatabase()
        {
            Recipe testRecipe = new Recipe("Pot Pie", "Microwave it");

            testRecipe.Save();

            testRecipe.Delete();

            Assert.Equal(0, Recipe.GetAll().Count);
        }
コード例 #3
0
        public void Recipe_Save_NoSaveOnDuplicateRecipe()
        {
            Recipe testRecipe = new Recipe("Pot Pie", "Microwave it");

            testRecipe.Save();
            Recipe secondRecipe = new Recipe("Pot Pie", "Microwave it");

            secondRecipe.Save();

            Assert.Equal(1, Recipe.GetAll().Count);
        }
コード例 #4
0
ファイル: HomeModule.cs プロジェクト: minhchan11/Recipe-App
        public static Dictionary <string, object> ModelMaker()
        {
            Dictionary <string, object> model = new Dictionary <string, object>
            {
                { "recipes", Recipe.GetAll() },
                { "categories", Category.GetAll() },
                { "ingredients", Ingredient.GetAll() }
            };

            return(model);
        }
コード例 #5
0
        public void Save_OneRecipe_RecipeSavedWithCorrectID()
        {
            //Arrange
            Recipe testRecipe = new Recipe("Pot Pie", "Microwave it");

            testRecipe.Save();
            Recipe savedRecipe = Recipe.GetAll()[0];

            //Act
            int output = savedRecipe.GetId();
            int verify = testRecipe.GetId();

            //Assert
            Assert.Equal(verify, output);
        }
コード例 #6
0
        public void Save_OneRecipe_RecipeSavedToDatabase()
        {
            //Arrange
            Recipe testRecipe = new Recipe("Pot Pie", "Microwave it");

            //Act
            testRecipe.Save();
            List <Recipe> output = Recipe.GetAll();
            List <Recipe> verify = new List <Recipe> {
                testRecipe
            };

            //Assert
            Assert.Equal(verify, output);
        }
コード例 #7
0
        public void SaveGetAll_ManyRecipes_ReturnListOfRecipes()
        {
            //Arrange
            Recipe recipeOne = new Recipe("Pot Pie", "Microwave it");

            recipeOne.Save();
            Recipe recipeTwo = new Recipe("Instant Ramen", "Boil it");

            recipeTwo.Save();

            //Act
            List <Recipe> output = Recipe.GetAll();
            List <Recipe> verify = new List <Recipe> {
                recipeOne, recipeTwo
            };

            //Assert
            Assert.Equal(verify, output);
        }