public void TestRetrieve() { props = (ProductProps)db.Retrieve(1); Assert.AreEqual("A4CS", props.code); Assert.AreEqual(56.50, props.price); //assert all }
public void TestDelete() { ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps props = (ProductProps)db.Retrieve(8); Assert.AreEqual(8, props.ID); db.Delete(props); var x = Assert.Throws <Exception>(() => db.Retrieve(8)); Assert.That(x.Message == "Record does not exist in the database."); }
public void TestDeleteProduct() { ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps props = (ProductProps)db.Retrieve(14); //14 SQ12 Murach's SQL Server 2012 57.50 2465 // delete ProductProps props from the database db.Delete(props); // attempting to retrieve props from the database should result in exception throw Assert.Throws <Exception>(() => db.Retrieve(14)); }
public void TestUpdate() { ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps props = (ProductProps)db.Retrieve(13); props.description = "Description"; bool ok = db.Update(props); Assert.AreEqual(true, ok); ProductProps propsUpdated = (ProductProps)db.Retrieve(13); Assert.AreEqual("Description", props.description); }
public void TestUpdate() { ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps props = (ProductProps)db.Retrieve(14); props.unitPrice = 55.50M; bool ok = db.Update(props); ProductProps propsUpdated = (ProductProps)db.Retrieve(14); //14 SQ12 Murach's SQL Server 2012 57.50 2465 Assert.AreEqual("SQ12", props.prodCode); Assert.AreEqual(55.50M, props.unitPrice); }
public void TestRetrieve() { ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps props = (ProductProps)db.Retrieve(2); Assert.AreEqual(2, props.ID); }
public void TestPropAndStringConstructor() { ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps props = (ProductProps)db.Retrieve(1); Product c = new Product(props, dataSource); Assert.AreEqual("A4CS ", c.ProductCode); }
public void TestProductTextDBRetrieve() { ProductSQLDB db = new ProductSQLDB(DataSource); ProductProps props = (ProductProps)db.Retrieve(1); Assert.AreEqual(1, props.id); Assert.AreEqual("A4CS", props.code); Assert.AreEqual(4637, props.onHandQty); }
public void TestDelete() { ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps props = new ProductProps(); props.ProductCode = "zzz "; props.Description = "zzz"; props.UnitPrice = 120.00m; props.OnHandQuantity = 1234; db.Create(props); ProductProps createdProduct = (ProductProps)db.Retrieve(props.ID); db.Delete(createdProduct); Assert.Throws <Exception>(() => db.Retrieve(props.ID)); }
public void TestUpdate() { ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps props = (ProductProps)db.Retrieve(1); props.ProductCode = "zzz "; props.Description = "zzz"; props.UnitPrice = 120.00m; props.OnHandQuantity = 1234; db.Update(props); ProductProps propsUpdated = (ProductProps)db.Retrieve(1); Assert.AreEqual("zzz ", propsUpdated.ProductCode); Assert.AreEqual("zzz", propsUpdated.Description); Assert.AreEqual(120.00m, propsUpdated.UnitPrice); Assert.AreEqual(1234, propsUpdated.OnHandQuantity); }
public void TestRetrieve() { ProductSQLDB db = new ProductSQLDB(dataSource); // remember to cast! ProductProps props = (ProductProps)db.Retrieve(6); // 6 CS10 Murach's C# 2010 56.50 80020 5136 Assert.AreEqual(6, props.ID); Assert.AreEqual("Murach's C# 2010", props.description); Assert.AreEqual(56.50, props.unitPrice); }
public void TestRetrieve() { ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps props = (ProductProps)db.Retrieve(1); //1 A4CS Murach's ASP.NET 4 Web Programming with C# 2010 56.5000 4637 1 Assert.AreEqual(1, props.ID); Assert.AreEqual("A4CS", props.ProductCode.Trim()); Assert.AreEqual("Murach's ASP.NET 4 Web Programming with C# 2010", props.Description); Assert.AreEqual(56.5000, props.UnitPrice); Assert.AreEqual(4637, props.OnHandQuantity); }
public void TestNewProductConstructor3() { // using ProductProps and connection string ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps pProps = (ProductProps)db.Retrieve(14); // 14 SQ12 Murach's SQL Server 2012 57.50 2465 Product p = new Product(pProps, dataSource); Console.WriteLine(p.ToString()); Assert.Greater(p.ToString().Length, 1); Assert.AreEqual("Murach's SQL Server 2012", p.Description); Assert.AreEqual(57.50M, p.UnitPrice); }
public void TestCreate() { ProductSQLDB db = new ProductSQLDB(dataSource); ProductProps props = new ProductProps(); props.ProductCode = "zzz "; props.Description = "zzz"; props.UnitPrice = 120.00m; props.OnHandQuantity = 1234; db.Create(props); ProductProps createdProduct = (ProductProps)db.Retrieve(props.ID); Assert.AreEqual("zzz ", createdProduct.ProductCode); Assert.AreEqual("zzz", createdProduct.Description); Assert.AreEqual(120.00m, createdProduct.UnitPrice); Assert.AreEqual(1234, createdProduct.OnHandQuantity); }
public void TestCreateProduct() { ProductSQLDB db = new ProductSQLDB(dataSource); // declare and instantiate new ProductProps p ProductProps p = new ProductProps(); p.prodCode = "FS30"; p.description = "Murach's F# 2015"; p.unitPrice = 50.00M; p.onHandQuantity = 100; // Create record for p in the database db.Create(p); // Retrieve Product p from the database and store in variable pCreated ProductProps pCreated = (ProductProps)db.Retrieve(p.ID); Assert.AreEqual("FS30", pCreated.prodCode); Assert.AreEqual(100, pCreated.onHandQuantity); }