public void ProductIsFromDifferentSupplier_ExceptionThrown() { var supplier = new SupplierBuilder().Id(123).Build(); var purchaseOrder = new PurchaseOrderBuilder() .Supplier(supplier) .Build(); var lineItem = new PurchaseOrderLineBuilder() .Product(new ProductBuilder().SupplierId(789).Build()) .Build(); Assert.Throws <PurchaseOrderTrackerException>(() => purchaseOrder.AddLineItem(lineItem)); }
public void ProductIsFromSameSupplier_LineItemAddedToCollection() { var supplier = new SupplierBuilder().Id(123).Build(); var purchaseOrder = new PurchaseOrderBuilder() .Supplier(supplier) .Build(); var lineItem = new PurchaseOrderLineBuilder() .Product(new ProductBuilder().SupplierId(123).Build()) .Build(); purchaseOrder.AddLineItem(lineItem); }
public void NullProduct_ThrowsArgumentNullException() { try { var line = new PurchaseOrderLineBuilder().Product(null).Build(); Assert.Fail("Expected exception to be thrown"); } catch (Exception ex) { Assert.That(ex, Is.InstanceOf <ArgumentNullException>()); Assert.That(ex.Message.ToLower(), Contains.Substring("product")); } }
public void Always_AssignsValues() { var product = new ProductBuilder().Build(); var line = new PurchaseOrderLineBuilder() .Product(product) .PurchasePrice(100) .PurchaseQty(10) .Build(); Assert.That(line.Product, Is.SameAs(product)); Assert.That(line.PurchasePrice, Is.EqualTo(100)); Assert.That(line.PurchaseQty, Is.EqualTo(10)); }