public void Construct_ShouldThrowDomainException_WithQuantity_LassThan1() { var product = new LookupIdTitle(Guid.NewGuid(), "product", "Koltuk"); var supplier = new LookupIdName(Guid.NewGuid(), "supplier"); var exception = Assert.Throws <DomainException>(() => { new VirtualStockCard(product, supplier, 0); }); Assert.Equal("Quantity cannot less than 1", exception.Message); }
public VirtualStockCard(LookupIdTitle product, LookupIdName supplier, double?quantity) : this(product, supplier) { if (quantity < 1) { throw new DomainException("Quantity cannot less than 1", new InvalidDataException()); } this.Quantity = quantity; }
public void Construct_ShouldThrowDomainException_WithProductOrSupplier() { var product = new LookupIdTitle(Guid.NewGuid(), "product", "Koltuk"); var supplier = new LookupIdName(Guid.NewGuid(), "supplier"); Assert.Throws <DomainException>(() => { new VirtualStockCard(product, null); }); Assert.Throws <DomainException>(() => { new VirtualStockCard(null, null); }); Assert.Throws <DomainException>(() => { new VirtualStockCard(null, supplier); }); }
public VirtualStockCard(LookupIdTitle product, LookupIdName supplier) { if (product == null) { throw new DomainException($"{nameof(PackageStock)}-{nameof(product)}", new ArgumentNullException()); } if (supplier == null) { throw new DomainException($"{nameof(PackageStock)}-{nameof(supplier)}", new ArgumentNullException()); } this.Product = product; this.Supplier = supplier; }
public VirtualStockCard(LookupIdTitle product, LookupIdName supplier, double?quantity, double?threshold) : this(product, supplier, quantity) { this.Threshold = threshold; }