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 SaveAndDeleteProductOptionTest() { ProductBusinessLayer layer = new ProductBusinessLayer(); Guid id = new Guid(); ProductOption test = new ProductOption(id, Guid.Parse("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"), "TestProductOption", "This is a unit test created product option"); layer.SaveNewProductOption(test); ProductOption postInsert = layer.GetOptionById(id); Assert.AreEqual(test.Id, postInsert.Id); Assert.AreEqual(test.ProductId, postInsert.ProductId); Assert.AreEqual(test.Name, postInsert.Name); Assert.AreEqual(test.Description, postInsert.Description); layer.DeleteProductOption(postInsert.Id); ProductOption postDelete = layer.GetOptionById(id); Assert.IsNull(postDelete); }