Example #1
0
        public void TestMarshallowsPriceConsumed()
        {
            var t       = new DatabaseAccess();
            var dbCosts = new DatabaseAccessCosts();
            var r       = new Recipe("Rocky Road Brownies")
            {
                id = 1
            };
            var i = new Ingredient("Marshmallows")
            {
                recipeId      = 1,
                ingredientId  = 1,
                measurement   = "2 cups",
                density       = 4.67m,
                sellingWeight = "24 ounces"
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(i, r);
            var myIngredient      = t.queryAllRelevantTablesSQLByIngredientName(i);
            var myIngredientsCost = dbCosts.queryCostTable();

            Assert.AreEqual(2.98m, myIngredient.sellingPrice);
            Assert.AreEqual(1.16m, myIngredient.priceOfMeasuredConsumption);
        }
Example #2
0
        public void TestDeleteIngredientFromIngredientsTableDeleteOnlyFromIngredientTable()
        {
            var t       = new DatabaseAccess();
            var dbI     = new DatabaseAccessIngredient();
            var dbC     = new DatabaseAccessConsumption();
            var dbCosts = new DatabaseAccessCosts();
            var dbDI    = new DatabaseAccessDensityInformation();
            var dbD     = new DatabaseAccessDensities();
            var HoneyButtermilkBread = new Recipe("Honey Buttermilk Bread")
            {
                id = 1, yield = 24
            };
            var breadFlour = new Ingredient("King Arthur Bread Flour")
            {
                ingredientId = 1, recipeId = 1, measurement = "6 cups", sellingWeight = "5 lb", typeOfIngredient = "bread flour", classification = "flour"
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(breadFlour, HoneyButtermilkBread);
            var myIngredientBox = dbI.myIngredientBox();

            dbI.DeleteIngredientFromIngredientTable(breadFlour);
            var myIngredientTableCount         = dbI.queryAllIngredientsFromIngredientTable().Count();
            var myIngredientBoxCount           = dbI.myIngredientBox().Count();
            var myCostTableCount               = dbCosts.queryCostTable().Count();
            var myDensitiesTableCount          = dbD.queryDensitiesTableAllRows().Count();
            var myDensityInformationTableCount = dbDI.queryDensityInfoTable().Count();
            var myConsumptionTable             = dbC.queryConsumptionTable().Count();

            Assert.AreEqual(0, myIngredientTableCount);
            Assert.AreEqual(1, myCostTableCount);
            Assert.AreEqual(1, myDensitiesTableCount);
            Assert.AreEqual(1, myConsumptionTable);
        }
Example #3
0
        public void TestMeasuredIngredientPriceIngredientsTablew()
        {
            var t       = new DatabaseAccess();
            var dbI     = new DatabaseAccessIngredient();
            var dbC     = new DatabaseAccessConsumption();
            var dbCosts = new DatabaseAccessCosts();
            var dbD     = new DatabaseAccessDensities();
            var rest    = new MakeRESTCalls();
            var r       = new Recipe("Wholesome Whole Wheat Bread")
            {
                id = 1
            };
            var i = new Ingredient("king arthur whole wheat flour")
            {
                recipeId      = 1,
                ingredientId  = 1,
                sellingWeight = "5 lb",
                measurement   = "1 1/2 cups",
                density       = 5.4m
            };

            t.initializeDatabase();
            dbI.insertIngredient(i, r);
            dbC.insertIngredientConsumtionData(i);
            dbD.insertIngredientDensityData(i);
            dbCosts.insertIngredientCostDataCostTable(i);
            var IngredientMeasuredPrice = dbI.MeasuredIngredientPrice(i);
            var myIngInfo = dbCosts.queryCostTable();

            Assert.AreEqual(.43m, IngredientMeasuredPrice);
        }
        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);
        }
Example #7
0
        public void TestInsertionIntoTables3()
        {
            var t       = new DatabaseAccess();
            var dbI     = new DatabaseAccessIngredient();
            var dbCosts = new DatabaseAccessCosts();
            var r       = new Recipe("Sour Cream Chocolate Cake")
            {
                id = 1
            };
            var i = new Ingredient("Hershey's Dark Cocoa")
            {
                recipeId      = 1,
                ingredientId  = 1,
                sellingWeight = "8 ounces",
                measurement   = "1 cup",
                density       = 4.16m
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(i, r);
            dbI.getIngredientMeasuredPrice(i, r);
            var myIngInfo      = dbI.queryAllIngredientsFromIngredientTable();
            var myInfoCostInfo = dbCosts.queryCostTable();

            Assert.AreEqual(1, myIngInfo.Count());
            Assert.AreEqual(3.34m, myInfoCostInfo[0].sellingPrice);
            Assert.AreEqual(1.74m, myIngInfo[0].priceOfMeasuredConsumption);
        }
Example #8
0
        public void TestInsertionIntoAllTables()
        {
            var t       = new DatabaseAccess();
            var dbI     = new DatabaseAccessIngredient();
            var dbC     = new DatabaseAccessConsumption();
            var dbCosts = new DatabaseAccessCosts();
            var dbD     = new DatabaseAccessDensities();
            var r       = new Recipe("Honey Buttermilk Bread")
            {
                id = 1
            };
            var i = new Ingredient("King Arthur Bread Flour")
            {
                recipeId      = 1,
                ingredientId  = 1,
                sellingWeight = "5 lb",
                measurement   = "6 cups",
                density       = 5.4m
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(i, r);
            var myIngInfo = dbI.queryAllIngredientsFromIngredientTable();
            var myIngCons = dbC.queryConsumptionTable();
            var myIngDens = dbD.queryDensitiesTableAllRows();
            var myIngCost = dbCosts.queryCostTable();

            Assert.AreEqual(1, myIngInfo.Count());
            Assert.AreEqual(1, myIngCons.Count());
            Assert.AreEqual(1, myIngDens.Count());
            Assert.AreEqual(1, myIngCost.Count());
        }
Example #9
0
        public void TestMeasuredIngredientPriceIngredientsTable2()
        {
            var t       = new DatabaseAccess();
            var dbI     = new DatabaseAccessIngredient();
            var dbC     = new DatabaseAccessConsumption();
            var dbCosts = new DatabaseAccessCosts();
            var dbD     = new DatabaseAccessDensities();
            var rest    = new MakeRESTCalls();
            var r       = new Recipe("Wholesome Whole Wheat Bread")
            {
                id = 1
            };
            var i = new Ingredient("King Arthur Whole Wheat Flour")
            {
                recipeId      = 1,
                ingredientId  = 1,
                sellingWeight = "5 lb",
                measurement   = "3 cups",
                density       = 5
            };
            var i2 = new Ingredient("Rumford Baking Powder")
            {
                recipeId      = 1,
                ingredientId  = 2,
                sellingWeight = "10 oz",
                measurement   = "1 teaspoon",
                density       = 8.4m
            };
            var i3 = new Ingredient("King Arthur All Purpose Flour")
            {
                recipeId      = 1,
                ingredientId  = 3,
                sellingWeight = "5 lb",
                measurement   = "2 cups",
                density       = 5
            };

            t.initializeDatabase();
            dbI.insertIngredient(i, r);
            dbI.insertIngredient(i2, r);
            dbI.insertIngredient(i3, r);
            dbC.insertIngredientConsumtionData(i);
            dbC.insertIngredientConsumtionData(i2);
            dbC.insertIngredientConsumtionData(i3);
            dbD.insertIngredientDensityData(i);
            dbD.insertIngredientDensityData(i2);
            dbD.insertIngredientDensityData(i3);
            dbCosts.insertIngredientCostDataCostTable(i);
            dbCosts.insertIngredientCostDataCostTable(i2);
            dbCosts.insertIngredientCostDataCostTable(i3);
            var ingredientMeasuredPrice1 = dbI.MeasuredIngredientPrice(i);
            var ingredient2MeasuredPrice = dbI.MeasuredIngredientPrice(i2);
            var ingredient3MeasuredPrice = dbI.MeasuredIngredientPrice(i3);

            Assert.AreEqual(.79m, ingredientMeasuredPrice1);
            Assert.AreEqual(.04m, ingredient2MeasuredPrice);
            Assert.AreEqual(.46m, ingredient3MeasuredPrice);
        }
        public ActionResult CostTable()
        {
            var dbC = new DatabaseAccessCosts();

            ViewBag.costtablesellingpriceasc   = dbC.queryCostTableSortedBySellilngPriceASC();
            ViewBag.costtablesellingpricedesc  = dbC.queryCostTableSortedBySellilngPriceDECS();
            ViewBag.costtablepriceperounceasc  = dbC.queryCostTableSortedByPricePerOunceASC();
            ViewBag.costtablepriceperouncedesc = dbC.queryCostTableSortedByPricePerOunceDESC();
            ViewBag.costtable = dbC.queryCostTable();
            return(View());
        }
Example #11
0
        public void TestDeleteIngredientFromIngredientsTableAndAccessOtherTablesForDeletedIngredient()
        {
            var t       = new DatabaseAccess();
            var dbI     = new DatabaseAccessIngredient();
            var dbC     = new DatabaseAccessConsumption();
            var dbCosts = new DatabaseAccessCosts();
            var dbD     = new DatabaseAccessDensities();
            var honeyButtermilkBread = new Recipe("Honey Buttermilk Bread")
            {
                id = 1, yield = 24
            };
            var cinnamonButtermilkBread = new Recipe("Cinnamon Buttermilk Bread")
            {
                id = 2, yield = 24
            };
            var breadFlour1 = new Ingredient("King Arthur Bread Flour")
            {
                ingredientId = 1, recipeId = 1, measurement = "6 cups", sellingWeight = "5 lb", typeOfIngredient = "bread flour", classification = "flour"
            };
            var breadFlour2 = new Ingredient("King Arthur Bread Flour")
            {
                ingredientId = 2, recipeId = 2, measurement = "6 cups", sellingWeight = "5 lb", typeOfIngredient = "bread flour", classification = "flour"
            };
            var salt = new Ingredient("Salt")
            {
                ingredientId = 3, recipeId = 2, measurement = "1 tablespoon", sellingWeight = "48 oz", typeOfIngredient = "salt", classification = "salt"
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(breadFlour1, honeyButtermilkBread);
            t.insertIngredientIntoAllTables(breadFlour2, cinnamonButtermilkBread);
            t.insertIngredientIntoAllTables(salt, cinnamonButtermilkBread);
            var myIngredientBox = dbI.myIngredientBox();

            dbI.DeleteIngredientFromIngredientTable(breadFlour1);
            dbI.DeleteIngredientFromIngredientTable(breadFlour2);
            var myIngredientTable  = dbI.queryAllIngredientsFromIngredientTable();
            var myCostTable        = dbCosts.queryCostTable();
            var myDensitiesTable   = dbD.queryDensitiesTableAllRows();
            var myConsumptionTable = dbC.queryConsumptionTable();

            Assert.AreEqual(1, myIngredientTable.Count());
            Assert.AreEqual("Salt", myIngredientTable[0].name);
            Assert.AreEqual(3, myCostTable.Count());
            Assert.AreEqual(3, myDensitiesTable.Count());
            Assert.AreEqual(2, myConsumptionTable.Count());
        }
        public void TestSortedQueryCostTablepricePerOunce()
        {
            var db   = new DatabaseAccess();
            var dbC  = new DatabaseAccessCosts();
            var cake = new Recipe("Cake")
            {
                id = 1, yield = 24
            };
            var bakingPowder = new Ingredient("Baking Powder")
            {
                ingredientId = 1, recipeId = 1, measurement = "1 teaspoon", sellingWeight = "10 oz", typeOfIngredient = "baking powder", classification = "rising agent"
            };
            var bakingSoda = new Ingredient("Baking Soda")
            {
                ingredientId = 2, recipeId = 1, measurement = "2 1/2 teaspoons", sellingWeight = "4 lb", typeOfIngredient = "baking soda", classification = "rising agent"
            };
            var vanillaExtract = new Ingredient("Vanilla Extract")
            {
                ingredientId = 3, recipeId = 1, measurement = "2 teaspoons", sellingWeight = "2 oz", typeOfIngredient = "vanilla extract", classification = "flavoring"
            };
            var softasilkCakeFlour = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 4, recipeId = 1, measurement = "2 cups 2 tablespoons", sellingWeight = "32 oz", typeOfIngredient = "cake flour", classification = "flour"
            };
            var eggs = new Ingredient("Egg whites, meringued")
            {
                ingredientId = 5, recipeId = 1, measurement = "3 eggs", sellingWeight = "3 dozen", sellingPrice = 3.69m, typeOfIngredient = "egg white", classification = "egg"
            };
            var milk = new Ingredient("Whole Milk")
            {
                ingredientId = 6, recipeId = 1, measurement = "1 1/2 cups", sellingWeight = "1 gallon", sellingPrice = 4.09m, typeOfIngredient = "milk", classification = "dairy"
            };
            var cakeIngredients = new List <Ingredient> {
                bakingPowder, bakingSoda, vanillaExtract, softasilkCakeFlour, eggs, milk
            };

            db.initializeDatabase();
            db.insertListOfIngredientsIntoAllTables(cakeIngredients, cake);
            var myCostTableSorted = dbC.queryCostTableSortedByPricePerOunceASC();

            Assert.AreEqual("Whole Milk", myCostTableSorted[0].name);
            Assert.AreEqual("Baking Soda", myCostTableSorted[1].name);
            Assert.AreEqual("Softasilk Cake Flour", myCostTableSorted[2].name);
            Assert.AreEqual("Egg whites, meringued", myCostTableSorted[3].name);
            Assert.AreEqual("Baking Powder", myCostTableSorted[4].name);
            Assert.AreEqual("Vanilla Extract", myCostTableSorted[5].name);
        }
        public void TestQueryCostTableRowByName()
        {
            var db      = new DatabaseAccess();
            var dbI     = new DatabaseAccessIngredient();
            var dbC     = new DatabaseAccessConsumption();
            var dbDI    = new DatabaseAccessDensityInformation();
            var dbD     = new DatabaseAccessDensities();
            var dbCosts = new DatabaseAccessCosts();
            var cake    = new Recipe("Cake")
            {
                id = 1, yield = 12
            };
            var softasilkCakeFlour = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 1, recipeId = 1, sellingWeight = "32 oz", measurement = "1 1/2 cups", typeOfIngredient = "cake flour", classification = "flour"
            };

            db.initializeDatabase();
            dbDI.insertDensityTextFileIntoDensityInfoDatabase();
            dbDI.queryDensityInfoTable();
            dbI.insertIngredient(softasilkCakeFlour, cake);
            var myIngredientInformation = dbI.queryIngredientFromIngredientsTableByName(softasilkCakeFlour);

            dbD.insertIngredientDensityData(softasilkCakeFlour);
            var myIngredientDensityInformation = dbD.queryIngredientFromDensityTableByName(softasilkCakeFlour);

            dbC.insertIngredientConsumtionData(softasilkCakeFlour);
            var myIngredientConsumptionInformation = dbC.queryConsumptionTableRowByName(softasilkCakeFlour);

            //i'm getting 0 for ounces remaining still... i need to figure that one out
            dbCosts.insertIngredientCostDataCostTable(softasilkCakeFlour);
            var myCostIngredientInformation = dbCosts.queryCostsTableByName(softasilkCakeFlour);

            Assert.AreEqual("Softasilk Cake Flour", myCostIngredientInformation.name);
            Assert.AreEqual(2.98m, myCostIngredientInformation.sellingPrice);
            Assert.AreEqual(.0931m, myCostIngredientInformation.pricePerOunce);
            Assert.AreEqual("32 oz", myCostIngredientInformation.sellingWeight);
        }
        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);
        }