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 void NegativeQuantityCheck() { var lookup = new LookupIdName(ObjectId.GenerateNewId().ToString(), "Test 1"); var price = new Price("TRY", 98.99); var product = new ProductInfo(lookup, price); Assert.Throws <DomainException>(() => { new BasketItem(product, -1); }); }
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 void BasketItem() { // Arrange var objectId = ObjectId.GenerateNewId().ToString(); var lookup = new LookupIdName(objectId, "Test 1"); var price = new Price("TRY", 98.99); var product = new ProductInfo(lookup, price); // Act var basketItem = new BasketItem(product, 1); // Assert Assert.Equal("Test 1", basketItem.Product.Product.Name); Assert.Equal("TRY", basketItem.Product.Price.Currency); Assert.NotNull(basketItem.Product.Product.Id); Assert.Equal(objectId, basketItem.Product.Product.Id); }
public PackageInfo(uint no, WarehouseLocation warehouseLocation, LookupIdName supplier, LookupIdName warehouse, double stockValue, string serialNumber, PackageStatus lastStatus, DateTime?productionDate, DateTime?expiredDate) { if (no < 0) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(no)}", new ArgumentNullException()); } if (warehouseLocation == null) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(warehouseLocation)}", new ArgumentNullException()); } if (supplier == null) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(supplier)}", new ArgumentNullException()); } if (warehouse == null) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(warehouse)}", new ArgumentNullException()); } if (stockValue < 0) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(stockValue)}", new ArgumentNullException()); } if (string.IsNullOrEmpty(serialNumber)) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(serialNumber)}", new ArgumentNullException()); } this.Location = warehouseLocation; this.No = no; this.Supplier = supplier; this.Warehouse = warehouse; this.StockValue = stockValue; this.SerialNumber = serialNumber; this.LastStatus = lastStatus; this.ExpiredDate = expiredDate; this.ProductionDate = productionDate; }
public VirtualStockCard(LookupIdTitle product, LookupIdName supplier, double?quantity, double?threshold) : this(product, supplier, quantity) { this.Threshold = threshold; }