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 UpdateProductTest() { ProductBusinessLayer layer = new ProductBusinessLayer(); Product test = layer.GetProductByID(Guid.Parse("8f2e9176-35ee-4f0a-ae55-83023d2db1a3")); string description = test.Description; test.Description = "This is changed for a unit test"; layer.UpdateProduct(test); Product postUpdate = layer.GetProductByID(Guid.Parse("8f2e9176-35ee-4f0a-ae55-83023d2db1a3")); Assert.AreEqual(test.Description, postUpdate.Description); postUpdate.Description = description; layer.UpdateProduct(postUpdate); }
public void GetByProductIdTest() { ProductBusinessLayer layer = new ProductBusinessLayer(); Product test = layer.GetProductByID(Guid.Parse("8f2e9176-35ee-4f0a-ae55-83023d2db1a3")); Assert.AreEqual("Samsung Galaxy S7", test.Name); Assert.AreEqual("Newest mobile product from Samsung.", test.Description); Assert.AreEqual(decimal.Parse("1024.99"), test.Price); Assert.AreEqual(decimal.Parse("16.99"), test.DeliveryPrice); }
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); }