public void should_fail_if_one_of_bought_product_amount_is_less_than_or_equal_to_zero(int invalidAmount) { PosService posService = CreatePosService(); var invalidProduct = new BoughtProduct("barcode001", invalidAmount); var validProduct = new BoughtProduct("barcode002", 1); BoughtProduct[] boughtProducts = {invalidProduct, validProduct}; Assert.Throws<ArgumentException>(() => posService.GetReceipt(boughtProducts)); }
public void should_merge_receipt_items() { CreateProductFixture( new Product {Barcode = "barcodesame", Name = "I do not care" }, new Product {Barcode = "barcodediff", Name = "I do not care" }); PosService posService = CreatePosService(); var boughtProduct = new BoughtProduct("barcodesame", 1); var sameBoughtProduct = new BoughtProduct("barcodesame", 2); var differentBoughtProduct = new BoughtProduct("barcodediff", 1); Receipt receipt = posService.GetReceipt( new[] {boughtProduct, differentBoughtProduct, sameBoughtProduct}); Assert.Equal(receipt.ReceiptItems.Single(i => i.Product.Barcode == "barcodesame").Amount, 3); Assert.Equal(receipt.ReceiptItems.Single(i => i.Product.Barcode == "barcodediff").Amount, 1); }
public void should_fail_if_bought_product_does_not_exist() { PosService posService = CreatePosService(); var notExistedProduct = new BoughtProduct("barcode", 1); Assert.Throws<ArgumentException>(() => posService.GetReceipt(new[] {notExistedProduct})); }