Esempio n. 1
0
        public void TestChocolateChips()
        {
            var dbD = new DatabaseAccessDensityInformation();
            var dbR = new DatabaseAccessRecipe();
            var t   = new DatabaseAccess();
            var r   = new Recipe("Chooalte Chip Cookies")
            {
                id = 1
            };
            var i = new Ingredient("Semi Sweet Morsels")
            {
                ingredientId = 1, recipeId = 1, sellingWeight = "36 oz", density = 5.35m, measurement = "1 cup"
            };

            //6.98    1.04
            t.initializeDatabase();
            //var filename = @"C:\Users\Rachel\Documents\Visual Studio 2015\Projects\RachelsRosesWebPages\RachelsRosesWebPages\densityTxtDatabase.txt";
            dbD.insertDensityTextFileIntoDensityInfoDatabase();
            t.insertIngredientIntoAllTables(i, r);
            var mydensityDataInformation = dbD.queryDensityInfoTable();
            var semiSweetMorsels         = t.queryAllRelevantTablesSQLByIngredientName(i);
            var myRecipes = dbR.MyRecipeBox();

            Assert.AreEqual("all purpose flour", mydensityDataInformation[0].name);
            Assert.AreEqual(1, myRecipes.Count());
            Assert.AreEqual(6.98m, semiSweetMorsels.sellingPrice);
            Assert.AreEqual(6.98m, myRecipes[0].ingredients[0].sellingPrice);
            Assert.AreEqual(1.04m, semiSweetMorsels.priceOfMeasuredConsumption);
            Assert.AreEqual(1.04m, myRecipes[0].ingredients[0].priceOfMeasuredConsumption);
        }
        public void TestOverwritingTheCostTable()
        {
            var t          = new DatabaseAccess();
            var dbC        = new DatabaseAccessCosts();
            var dbR        = new DatabaseAccessRecipe();
            var yellowCake = new Recipe("Yellow Cake")
            {
                id = 1, yield = 12
            };
            var milk = new Ingredient("Whole Milk")
            {
                ingredientId = 1, recipeId = 1, measurement = "1 cup", sellingWeight = "1 gallon", typeOfIngredient = "milk", classification = "dairy"
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(milk, yellowCake);
            var myIngredient = t.queryAllRelevantTablesSQLByIngredientName(milk);

            milk.sellingPrice = 2.98m;
            dbC.updateCostDataTable(milk);
            var myCostIngredient = dbC.queryCostTable();

            t.updateAllTables(milk, yellowCake);
            var myUpdatedIngredient = t.queryAllRelevantTablesSQLByIngredientName(milk);
            var myRecipeBox         = dbR.MyRecipeBox();

            Assert.AreEqual(1, myRecipeBox[0].ingredients.Count());
            Assert.AreEqual(2.98m, myUpdatedIngredient.sellingPrice);
            Assert.AreEqual(8.2m, myIngredient.density);
            Assert.AreEqual(.19m, myUpdatedIngredient.priceOfMeasuredConsumption);
            Assert.AreEqual(.0233m, myUpdatedIngredient.pricePerOunce);
        }
        public void TestDeleteIngredientFromCostTable()
        {
            var t     = new DatabaseAccess();
            var dbC   = new DatabaseAccessCosts();
            var dbR   = new DatabaseAccessRecipe();
            var bread = new Recipe("Bread")
            {
                id = 1
            };
            var honey = new Ingredient("Honey")
            {
                ingredientId = 1, recipeId = 1, typeOfIngredient = "honey", measurement = "1/3 cup", sellingWeight = "32 oz"
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(honey, bread);
            var myRecipes     = dbR.MyRecipeBox();
            var myIngredients = t.queryAllRelevantTablesSQLByIngredientName(honey);

            dbC.DeleteIngredientFromCostTable(honey);
            var myCostIngredients = dbC.queryCostTable();

            Assert.AreEqual(1, myRecipes.Count());
            Assert.AreEqual(1, myRecipes[0].ingredients.Count());
            Assert.AreEqual(0, myCostIngredients.Count());
        }
        public void TestOverwritingTheCostTable3()
        {
            var t             = new DatabaseAccess();
            var dbC           = new DatabaseAccessCosts();
            var dbR           = new DatabaseAccessRecipe();
            var chocolateCake = new Recipe("Chocolate Cake")
            {
                id = 1, yield = 16
            };
            var softasilk = new Ingredient("Softasilk Flour")
            {
                recipeId = 1, ingredientId = 1, sellingWeight = "32 oz", measurement = "3 cups", typeOfIngredient = "cake flour", classification = "flour"
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(softasilk, chocolateCake);
            var myIngredient = t.queryAllRelevantTablesSQLByIngredientName(softasilk);

            softasilk.sellingPrice = 5m;
            var costTable = dbC.queryCostTable();

            t.updateAllTables(softasilk, chocolateCake);
            var myUpdatedIngredient = t.queryAllRelevantTablesSQLByIngredientName(softasilk);
            var myRecipeBox         = dbR.MyRecipeBox();

            Assert.AreEqual(1.26m, myIngredient.priceOfMeasuredConsumption);
            Assert.AreEqual(2.11m, myUpdatedIngredient.priceOfMeasuredConsumption);
            Assert.AreEqual(2.11m, myRecipeBox[0].aggregatedPrice);
        }
Esempio n. 5
0
        public void TestGettingUniqueEntriesINIngredientTable()
        {
            var t               = new DatabaseAccess();
            var dbR             = new DatabaseAccessRecipe();
            var dbI             = new DatabaseAccessIngredient();
            var fluffyWhiteCake = new Recipe("Fluffy White Cake")
            {
                id = 1, yield = 12
            };
            var chocolateCake = new Recipe("My Favorite Chocolat Cake")
            {
                id = 2, yield = 18
            };
            var yellowCake = new Recipe("Yellow Cake")
            {
                id = 3, yield = 16
            };
            var softasilk = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 1, recipeId = 1, measurement = "2 cups 2 tablespoons", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var softasilk2 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 2, recipeId = 2, measurement = "3 cups", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var softasilk3 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 3, recipeId = 3, measurement = "1 1/2 cups", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var bakingPowder = new Ingredient("Baking Powder")
            {
                ingredientId = 4, recipeId = 3, measurement = "2 teaspoons", typeOfIngredient = "baking powder", sellingWeight = "10 oz"
            };
            var yellowCakeIngredients = new List <Ingredient> {
                softasilk3, bakingPowder
            };
            var myIngredientBox = new List <Ingredient> {
                softasilk, softasilk2, softasilk3, bakingPowder
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(softasilk, fluffyWhiteCake);
            t.insertIngredientIntoAllTables(softasilk2, chocolateCake);
            t.insertListOfIngredientsIntoAllTables(yellowCakeIngredients, yellowCake);
            var myIngredientsTable       = dbI.queryAllIngredientsFromIngredientTable();
            var myRecipeBox              = dbR.MyRecipeBox();
            var myDistictIngredientTable = dbI.myDistinctIngredientNamesSorted();
            var myIngredientBoxFilled    = t.queryAllTablesForAllIngredients(myIngredientBox);

            Assert.AreEqual(4, myIngredientsTable.Count());
            Assert.AreEqual(2, myDistictIngredientTable.Count());
            Assert.AreEqual("Softasilk Cake Flour", myDistictIngredientTable[0]);
            Assert.AreEqual("Baking Powder", myDistictIngredientTable[1]);
            Assert.AreEqual(.89m, softasilk.priceOfMeasuredConsumption);
            Assert.AreEqual(1.26m, softasilk2.priceOfMeasuredConsumption);
            Assert.AreEqual(.63m, softasilk3.priceOfMeasuredConsumption);
            Assert.AreEqual(.10m, bakingPowder.priceOfMeasuredConsumption);
        }
        public void TestOverwritingTheCostTable2()
        {
            var t             = new DatabaseAccess();
            var dbC           = new DatabaseAccessCosts();
            var dbR           = new DatabaseAccessRecipe();
            var chocolateCake = new Recipe("Chocolate Cake")
            {
                id = 1, yield = 24
            };
            var yellowCake = new Recipe("Yellow Cake")
            {
                id = 2, yield = 24
            };
            var honeyButtermilkBread = new Recipe("Honey Buttermilk Bread")
            {
                id = 3, yield = 24
            };
            var sourCream = new Ingredient("Sour Cream")
            {
                ingredientId = 1, recipeId = 1, measurement = "1 cup", sellingWeight = "16 oz", typeOfIngredient = "sour cream", classification = "dairy"
            };
            var milk = new Ingredient("Whole Milk")
            {
                ingredientId = 2, recipeId = 2, measurement = "1 1/2 cups", sellingWeight = "1 gallon", typeOfIngredient = "milk", classification = "dairy"
            };
            var butter = new Ingredient("Unsalted Butter")
            {
                ingredientId = 3, recipeId = 3, measurement = "1/4 cup", sellingWeight = "1 lb", typeOfIngredient = "butter", classification = "dairy"
            };
            var buttermilk = new Ingredient("Buttermilk")
            {
                ingredientId = 4, recipeId = 3, measurement = "2 cups", sellingWeight = "1/4 gallon", typeOfIngredient = "buttermilk", classification = "dairy"
            };
            var honeyButtermilkBreadIngredients = new List <Ingredient> {
                butter, buttermilk
            };
            var allIngredients = new List <Ingredient> {
                sourCream, milk, butter, buttermilk
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(sourCream, chocolateCake);
            t.insertIngredientIntoAllTables(milk, yellowCake);
            t.insertListOfIngredientsIntoAllTables(honeyButtermilkBreadIngredients, honeyButtermilkBread);
            var myIngredients = t.queryAllTablesForAllIngredients(allIngredients);

            sourCream.sellingPrice  = 1.69m;
            milk.sellingPrice       = 2.98m;
            butter.sellingPrice     = 3.99m;
            buttermilk.sellingPrice = 1.69m;
            var costTable = dbC.queryCostTable();

            t.updateAllTables(sourCream, chocolateCake);
            t.updateAllTables(milk, yellowCake);
            t.updateAllTablesForAllIngredients(honeyButtermilkBreadIngredients, honeyButtermilkBread);
            var myUpdatedIngredients = t.queryAllTablesForAllIngredients(allIngredients);
            var myRecipeBox          = dbR.MyRecipeBox();

            Assert.AreEqual(1.69m, myUpdatedIngredients[0].sellingPrice);
            Assert.AreEqual(2.98m, myUpdatedIngredients[1].sellingPrice);
            Assert.AreEqual(3.99m, myUpdatedIngredients[2].sellingPrice);
            Assert.AreEqual(1.69m, myUpdatedIngredients[3].sellingPrice);
            Assert.AreEqual(8.6m, myUpdatedIngredients[0].density);
            Assert.AreEqual(8.2m, myUpdatedIngredients[1].density);
            Assert.AreEqual(8m, myUpdatedIngredients[2].density);
            Assert.AreEqual(8.2m, myUpdatedIngredients[3].density);
            Assert.AreEqual(.91m, myUpdatedIngredients[0].priceOfMeasuredConsumption);
            Assert.AreEqual(.91m, myRecipeBox[0].ingredients[0].priceOfMeasuredConsumption);
            Assert.AreEqual(.29m, myUpdatedIngredients[1].priceOfMeasuredConsumption);
            Assert.AreEqual(.29m, myRecipeBox[1].ingredients[0].priceOfMeasuredConsumption);
            Assert.AreEqual(.5m, myUpdatedIngredients[2].priceOfMeasuredConsumption);
            Assert.AreEqual(.5m, myRecipeBox[2].ingredients[0].priceOfMeasuredConsumption);
            Assert.AreEqual(.87m, myUpdatedIngredients[3].priceOfMeasuredConsumption);
            Assert.AreEqual(.87m, myRecipeBox[2].ingredients[1].priceOfMeasuredConsumption);
            Assert.AreEqual(.91m, myRecipeBox[0].aggregatedPrice);
            Assert.AreEqual(.29m, myRecipeBox[1].aggregatedPrice);
            Assert.AreEqual(1.37m, myRecipeBox[2].aggregatedPrice);
        }
        public List <Recipe> getRecipes()
        {
            var db = new DatabaseAccessRecipe();

            return(db.MyRecipeBox());
        }