Esempio n. 1
0
        public void TestListOfIngredientsUpdateDensityInfoTable()
        {
            var t             = new DatabaseAccess();
            var dbD           = new DatabaseAccessDensityInformation();
            var i             = new Ingredient("all purpose flour");
            var i2            = new Ingredient("pastry flour");
            var i3            = new Ingredient("vanilla extract");
            var myIngredients = new List <Ingredient> {
                i, i2, i3
            };

            t.initializeDatabase();
            dbD.insertListIntoDensityInfoDatabase(myIngredients);
            var BeforeMyDensityInfoTable = dbD.queryDensityInfoTable();

            i.density  = 5m;
            i2.density = 4.25m;
            i3.density = 6.86m;
            dbD.updateListOfIngredientsInDensityInfoTable(myIngredients);
            var AfterMyDensityInfoTable = dbD.queryDensityInfoTable();

            Assert.AreEqual(3, BeforeMyDensityInfoTable.Count());
            Assert.AreEqual(3, AfterMyDensityInfoTable.Count());
            Assert.AreEqual(0, BeforeMyDensityInfoTable[0].density);
            Assert.AreEqual(0, BeforeMyDensityInfoTable[1].density);
            Assert.AreEqual(0, BeforeMyDensityInfoTable[2].density);
            Assert.AreEqual(5m, AfterMyDensityInfoTable[0].density);
            Assert.AreEqual(4.25m, AfterMyDensityInfoTable[1].density);
            Assert.AreEqual(6.86m, AfterMyDensityInfoTable[2].density);
        }
Esempio n. 2
0
        public void TestInsertListOfIngredientsIntoDensityInfo()
        {
            var t    = new DatabaseAccess();
            var dbDI = new DatabaseAccessDensityInformation();
            var i    = new Ingredient("all purpose flour")
            {
                density = 5m
            };
            var i2 = new Ingredient("pastry flour")
            {
                density = 4.25m
            };
            var i3 = new Ingredient("vanilla extract")
            {
                density = 6.86m
            };
            var myIngredients = new List <Ingredient> {
                i, i2, i3
            };

            t.initializeDatabase();
            dbDI.insertListIntoDensityInfoDatabase(myIngredients);
            var myDensityInfoTable = dbDI.queryDensityInfoTable();

            Assert.AreEqual(3, myDensityInfoTable.Count());
            Assert.AreEqual(i.name, myDensityInfoTable[0].name);
            Assert.AreEqual(i.density, myDensityInfoTable[0].density);
            Assert.AreEqual(i2.name, myDensityInfoTable[1].name);
            Assert.AreEqual(i2.density, myDensityInfoTable[1].density);
            Assert.AreEqual(i3.name, myDensityInfoTable[2].name);
            Assert.AreEqual(i3.density, myDensityInfoTable[2].density);
        }