public void TestRemoveItemFromPurchaseOrder() { var productController = new ProductController(new LoggerStub <ProductController>()); var supplierControl = new SupplierController(new LoggerStub <SupplierController>()); var products = productController.SearchProducts(string.Empty, true).Result as List <Product>; var c = string.Format("{0:000}", products.Count); var suppliers = supplierControl.Search("Test").Result as List <Supplier>; Assert.IsTrue(suppliers.Count > 0, "No Test Suppliers please run the create test suppliers test"); var supplier = suppliers.FirstOrDefault(); Assert.IsNotNull(supplier, "NULL Value in list of suppliers"); Assert.IsTrue(!string.IsNullOrEmpty(supplier.Name), "Supplier has no name"); Assert.IsTrue(!string.IsNullOrEmpty(supplier.SupplierCode), "Supplier has no supplier code"); var product = new AddProductToSupplierModel { Description = "Test product", Price = "59.99", ProductCode = $"TEST-PRODUCT-CODE-{c}", SupplierId = supplier.Id.ToString() }; Guid productId = productController.AddProductToSupplier(product).Result; var poController = new PurchaseOrderController(new LoggerStub <PurchaseOrderController>()); var poId = poController.CreatePurchaseOrder(supplier.Id).Result; Assert.IsNotNull(poId, "Purchase order controller returned NULL"); Assert.AreNotEqual(poId, Guid.Empty, "Purchase Order ID is Empty GUID"); var poiId = poController.AddProductToPurchaseOrder(poId, productId, 5).Result; Assert.IsNotNull(poiId, "Failed to add item to purchase order"); Assert.AreNotEqual(poiId, Guid.Empty, "Purchase Order Item ID is Empty GUID"); var removed = poController.RemoveItemFromPurchaseOrder(poId, productId).Result; Assert.IsTrue(removed, "Item was not removed from the purchase order"); }
public void AddProductToSupplierTest() { var controller = new SupplierController(new LoggerStub <SupplierController>()); List <Supplier> suppliers = controller.Search("Test Supplier").Result as List <Supplier>; var no = string.Format("{0:000}", suppliers.Count); var supplier = new Supplier { Name = "Test Supplier", SupplierCode = $"TEST-SUPPLIER-CODE-{no}" }; var supplierId = controller.AddSupplier(supplier.Name, supplier.SupplierCode).Result; Assert.IsNotNull(supplierId, "Failed to create supplier"); var dataSupplier = controller.GetSupplier(supplier.SupplierCode).Result; Assert.IsNotNull(dataSupplier, "Could not read supplier from Database"); Assert.AreEqual(supplier.Name, dataSupplier.Name, "Supplier Name Corrupted on Save"); Assert.AreEqual(supplier.SupplierCode, dataSupplier.SupplierCode, "Supplier Code Corrupted on Save"); var productController = new ProductController(new LoggerStub <ProductController>()); var supplierControl = new SupplierController(new LoggerStub <SupplierController>()); var products = productController.SearchProducts(string.Empty, true).Result as List <Product>; var c = string.Format("{0:000}", products.Count); Assert.IsTrue(!string.IsNullOrEmpty(supplier.Name), "Supplier has no name"); Assert.IsTrue(!string.IsNullOrEmpty(supplier.SupplierCode), "Supplier has no supplier code"); var product = new AddProductToSupplierModel { Description = "Test product", Price = "59.99", ProductCode = $"TEST-PRODUCT-CODE-{c}", SupplierId = supplier.Id.ToString() }; Guid productId = productController.AddProductToSupplier(product).Result; Assert.IsNotNull(productId, "Failed to add prodcut to supplier"); Assert.AreNotEqual(productId, Guid.Empty, "Product ID is empty GUID"); }