示例#1
0
        public void TestUpdateProduct()
        {
            Product p2 = new Product();

            p2.ProductCode    = "zzzz";
            p2.Description    = "Test Product 2";
            p2.UnitPrice      = 99.99M;
            p2.OnHandQuantity = 2;

            Product p3 = new Product();

            p3.ProductCode    = "zzzz2";
            p3.Description    = "Updated Test Product 2";
            p3.UnitPrice      = 99.99M;
            p3.OnHandQuantity = 3;

            // add Product p2 to ProductDB
            ProductDB.AddProduct(p2);
            // update pd with p3 properties
            ProductDB.UpdateProduct(p2, p3);
            // GetProduct p3 from ProductDB and store in variable q
            Product q = ProductDB.GetProduct(p3.ProductCode);

            // ProductCode of q should still be equal to zzzz2
            Assert.AreEqual("zzzz2     ", q.ProductCode);
            // OnHandQuantity should reflect update and be equal to 3
            Assert.AreEqual(3, q.OnHandQuantity);

            // Delete Product p3 from ProductDB (since no test set-up)
            ProductDB.DeleteProduct(p3);
        }
示例#2
0
        public void TestUpdateProduct()
        {
            Product p = new Product();

            p.ProductCode    = "XYZ1      ";
            p.Description    = "test product 1";
            p.Price          = 15.00m;
            p.OnHandQuantity = 10;

            Product updatedP = new Product();

            updatedP.ProductCode    = "XYZ1      ";
            updatedP.Description    = "test product 1";
            updatedP.Price          = 20.00m;
            updatedP.OnHandQuantity = 5;

            bool isUpdated = ProductDB.UpdateProduct(p, updatedP);

            Assert.IsTrue(isUpdated);
        }
示例#3
0
        public void TestUpdateProduct()
        {
            Product p1 = new Product();
            Product p2 = new Product();

            p1.ProductCode    = "ABCD      ";
            p1.Description    = "Test product one";
            p1.UnitPrice      = 20.00M;
            p1.OnHandQuantity = 20;

            ProductDB.AddProduct(p1);

            p2.ProductCode    = "EFGH      ";
            p2.Description    = "Test product two";
            p2.UnitPrice      = 30.00M;
            p2.OnHandQuantity = 30;

            ProductDB.UpdateProduct(p1, p2);

            Product retrievedProduct = ProductDB.GetProduct(p2.ProductCode);

            Assert.AreEqual("EFGH      ", retrievedProduct.ProductCode);
        }
示例#4
0
 public void TestUpdateProduct()
 {
     ProductDB.UpdateProduct(p1, p2);
     Assert.AreEqual(3, p2.OnHandQuantity);
 }
示例#5
0
 public void UpdateProduct()
 {
     Assert.True(ProductDB.UpdateProduct(this.testProduct, this.testProduct2));
     Assert.True(ProductDB.UpdateProduct(this.testProduct2, this.testProduct));
 }
示例#6
0
        public void TestUpdateProduct()
        {
            //need to retrieve product from data base
            //either use clone or can use two variables
            //update values to change except for the ProductCode
            //Because ProductCode is what references the actual product and knows what to update.

            Product p = new Product();

            p.ProductCode    = "ZZZ1";
            p.Description    = "Test Product";
            p.UnitPrice      = 99.9M;
            p.OnHandQuantity = 2;
            ProductDB.DeleteProduct(p);
            ProductDB.AddProduct(p);



            Product op = ProductDB.GetProduct("ZZZ1     ");
            Product np = ProductDB.GetProduct("ZZZ1     ");

            Assert.AreEqual(2, op.OnHandQuantity);
            Assert.AreEqual(2, np.OnHandQuantity);


            np.OnHandQuantity = 3;


            ProductDB.UpdateProduct(op, np);
            Product pp = ProductDB.GetProduct("ZZZ1     ");



            Assert.AreEqual(3, pp.OnHandQuantity);

            //np.Description = "Replaced Test Product";
            //np.UnitPrice = 00.0M;
            //np.OnHandQuantity = 3;

            //ProductDB.UpdateProduct(op, np);

            //Assert.AreEqual(3, op.OnHandQuantity);



            // My previous thoughts when I wasn't getting the product and expecting the
            // method to change the values.

            //Product op = new Product();
            //op.ProductCode = "ZZZZ";
            //op.Description = "Test Product";
            //op.UnitPrice = 99.9M;
            //op.OnHandQuantity = 2;

            //Product np = new Product();
            //np.ProductCode = "YYYY";
            //np.Description = "Replaced Test Product";
            //np.UnitPrice = 00.0M;
            //np.OnHandQuantity = 3;


            //ProductDB.UpdateProduct(op, np);

            //Trying to test that the Product op was switched to the np values.
            //Does not appear to be working this way.

            // Assert.AreEqual("YYYY      ", op.ProductCode);
        }