public void DeletingProductAlsoDeletesOptionsTest() { ProductBusinessLayer layer = new ProductBusinessLayer(); Guid testProductId = new Guid(); Guid testProductOptionId = new Guid(); Product testProduct = new Product(testProductId, "TestProduct", "This Product is made by a unit test", 1, 2); layer.SaveNewProduct(testProduct); ProductOption testProductOption = new ProductOption(testProductOptionId, testProductId, "TestProductOption", "This option is made by a unit test"); layer.SaveNewProductOption(testProductOption); //Check that they were saved successfully Product postInsertProduct = layer.GetProductByID(testProductId); ProductOption postInsertOption = layer.GetOptionById(testProductOptionId); Assert.IsNotNull(postInsertOption); Assert.IsNotNull(postInsertProduct); Assert.AreEqual(postInsertProduct.Id, postInsertOption.ProductId); layer.DeleteProduct(testProductId); Product postDeleteProduct = layer.GetProductByID(testProductId); ProductOption postDeleteOption = layer.GetOptionById(testProductOptionId); Assert.IsNull(postDeleteOption); Assert.IsNull(postDeleteProduct); }
public void SaveAndDeleteProductTest() { ProductBusinessLayer layer = new ProductBusinessLayer(); Guid id = new Guid(); Product Test = new Product(id, "TestProduct", "This is a test product for unit testing purposes", 1, 2); layer.SaveNewProduct(Test); Product postInsert = layer.GetProductByID(id); Assert.AreEqual(Test.Id, postInsert.Id); Assert.AreEqual(Test.Name, postInsert.Name); Assert.AreEqual(Test.Description, postInsert.Description); Assert.AreEqual(Test.Price, postInsert.Price); Assert.AreEqual(Test.DeliveryPrice, postInsert.DeliveryPrice); layer.DeleteProduct(postInsert.Id); Product postDelete = layer.GetProductByID(id); Assert.IsNull(postDelete); }