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 GetOptionByIdTest() { ProductBusinessLayer layer = new ProductBusinessLayer(); ProductOption test = layer.GetOptionById(Guid.Parse("0643ccf0-ab00-4862-b3c5-40e2731abcc9")); Assert.AreEqual("White", test.Name); Assert.AreEqual("White Samsung Galaxy S7", test.Description); Assert.AreEqual(Guid.Parse("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"), test.ProductId); }
public void UpdateProductOptionTest() { ProductBusinessLayer layer = new ProductBusinessLayer(); ProductOption test = layer.GetOptionById(Guid.Parse("0643ccf0-ab00-4862-b3c5-40e2731abcc9")); string description = test.Description; test.Description = "This has been changed by a unit test"; layer.UpdateProductOption(test); ProductOption postUpdate = layer.GetOptionById(Guid.Parse("0643ccf0-ab00-4862-b3c5-40e2731abcc9")); Assert.AreEqual(test.Description, postUpdate.Description); postUpdate.Description = description; layer.UpdateProductOption(postUpdate); }
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); }