Exemplo n.º 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);
        }
        public void TestGetProduct()
        {
            Product product = ProductDB.GetProduct("2JST      ");

            Assert.AreEqual("2JST      ", product.ProductCode);
            Assert.AreEqual(6937, product.OnHandQuantity);
        }
Exemplo n.º 3
0
        public void TestDeleteProduct()
        {
            //Product p = new Product();
            //p.ProductCode = "ZZZZ";
            //p.Description = "Delete Test Product";
            //p.UnitPrice = 11.1M;
            //p.OnHandQuantity = 4;

            //Already added the Product p
            // ProductDB.AddProduct(p);

            //Assert.AreEqual(4, p.OnHandQuantity);


            Product d = ProductDB.GetProduct("ZZZZ      ");

            Assert.AreEqual("ZZZZ      ", d.ProductCode);


            Assert.IsTrue(ProductDB.DeleteProduct(d));
            Assert.IsNull(ProductDB.GetProduct("ZZZZ      "));



            //Assert.AreEqual(null, d1.ProductCode);
            //Assert.AreEqual(null, d1.OnHandQuantity);

            // Assert.Throws<SqlException>( () => ProductDB.GetProduct("QQQ2      "));

            // If it is working would I need to be testing for the exception??
        }
Exemplo n.º 4
0
        public void TestDeleteProduct()
        {
            Product p = ProductDB.GetProduct("EFGH      ");

            ProductDB.DeleteProduct(p);
            Assert.IsNull(ProductDB.GetProduct(p.ProductCode));
        }
Exemplo n.º 5
0
        public void TestGetProduct()
        {
            // note: spaces needed due to ProductCode being char, not varchar
            Product p = ProductDB.GetProduct("2JST      ");

            Assert.AreEqual("2JST      ", p.ProductCode);
            Assert.AreEqual(6937, p.OnHandQuantity);
        }
Exemplo n.º 6
0
        public void getProduct()
        {
            Product fromDB = ProductDB.GetProduct(this.testProduct.ProductCode);

            Assert.AreEqual(fromDB.Description, testProduct.Description);
            Assert.AreEqual(fromDB.UnitPrice, testProduct.UnitPrice);
            Assert.AreEqual(fromDB.OnHandQuantity, testProduct.OnHandQuantity);
        }
Exemplo n.º 7
0
        public void TestAddProduct()
        {
            Product p = new Product();

            p.ProductCode    = "XYZ1      ";
            p.Description    = "test product 1";
            p.Price          = 15.00m;
            p.OnHandQuantity = 10;
            int     moddedRows = ProductDB.AddProduct(p);
            Product dbP        = ProductDB.GetProduct("XYZ1      ");

            Assert.AreEqual(moddedRows, 1);
        }
        public void TestAddProduct()
        {
            Product p = new Product();

            p.ProductCode    = "ZZZZ";
            p.Description    = "Test Product";
            p.UnitPrice      = 99.99M;
            p.OnHandQuantity = 2;
            ProductDB.AddProduct(p);

            p = ProductDB.GetProduct("ZZZZ      ");
            Assert.AreEqual("ZZZZ      ", p.ProductCode);
            Assert.AreEqual(2, p.OnHandQuantity);
        }
Exemplo n.º 9
0
        public void TestDeleteProduct()
        {
            // note: as written, this test only functions after TestAddProduct is run
            Product p = new Product();

            p.ProductCode    = "2222";
            p.Description    = "Test Product";
            p.UnitPrice      = 100.00M;
            p.OnHandQuantity = 12;

            // delete Product p from ProductDB
            ProductDB.DeleteProduct(p);
            // GetProduct p in ProductDB should be equal to null (since it is deleted)
            Assert.AreEqual(null, ProductDB.GetProduct(p.ProductCode));
        }
Exemplo n.º 10
0
        public void TestInsertProduct()
        {
            Product p = new Product();

            p.ProductCode    = "ZZZZ      ";
            p.Description    = "Test Product";
            p.UnitPrice      = 99.99M;
            p.OnHandQuantity = 2;
            ProductDB.AddProduct(p);
            Assert.AreEqual("ZZZZ      ", p.ProductCode);
            Assert.AreEqual("Test Product", p.Description);
            Assert.AreEqual(99.99M, p.UnitPrice);
            Assert.AreEqual(2, p.OnHandQuantity);
            ProductDB.DeleteProduct(p);
            Assert.IsNull(ProductDB.GetProduct(p.ProductCode));
        }
Exemplo n.º 11
0
        public void Setup()
        {
            Product p = new Product();

            p.ProductCode    = "ZZZZ";
            p.Description    = "Test Product";
            p.UnitPrice      = 99.9M;
            p.OnHandQuantity = 2;

            if (ProductDB.GetProduct("ZZZZ     ") != null)
            {
                ProductDB.DeleteProduct(p);
            }
            else
            {
                ProductDB.AddProduct(p);
            }
        }
Exemplo n.º 12
0
        public void TestInsertProduct()
        {
            //Need to change ProductCode everytime test is run otherwise
            //it will give an error that primary key is not unique.
            Product p = new Product();

            p.ProductCode    = "ZZZZ";
            p.Description    = "Test Product";
            p.UnitPrice      = 99.9M;
            p.OnHandQuantity = 2;

            //ProductDB.AddProduct(p);

            Product p1 = ProductDB.GetProduct("ZZZZ     ");

            Assert.AreEqual("ZZZZ      ", p1.ProductCode);
            Assert.AreEqual(2, p1.OnHandQuantity);
        }
Exemplo n.º 13
0
        public void TestAddProduct()
        {
            // note: this test can only be run once until you have written a set-up
            //  the set-up will reset the database, so that the test can be run

            // create a new Product and set properties
            Product p = new Product();

            p.ProductCode    = "2222";
            p.Description    = "Test Product";
            p.UnitPrice      = 100.00M;
            p.OnHandQuantity = 12;

            // add the new Product p to the ProductDB
            ProductDB.AddProduct(p);
            // get Product w/ProductCode 2222 and store in variable p
            p = ProductDB.GetProduct("2222      ");
            // ProductCode of p should be equal to 2222
            Assert.AreEqual("2222      ", p.ProductCode);
            // OnHandQuantity of p should be equal to 12
            Assert.AreEqual(12, p.OnHandQuantity);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        public void TestGetProduct()
        {
            Product p = ProductDB.GetProduct("XYZ1");

            Assert.IsTrue(p != null);
        }
Exemplo n.º 16
0
        public void TestGetProduct()
        {
            Product p = ProductDB.GetProduct("VB10");

            Assert.AreEqual("Murach's Visual Basic 2010", p.Description.Trim());
        }
Exemplo n.º 17
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);
        }