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 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); }
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)); }
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); } }
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); }
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); }
public void TestAddProduct() { ProductDB.AddProduct(p1); Assert.AreEqual("TEST", p1.ProductCode); }
public void InsertProduct() { Assert.True(ProductDB.AddProduct(this.testProduct)); }
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); }