public void ReceiptTest() { // Arrange var receipt = new Receipt(); // Act receipt.AddItem("Mjölk", 10.95M, 2); receipt.AddItem("Bröd", 18.5M, 1); receipt.AddItem("Smör", 45.50M, 1); decimal total = receipt.Total(); // Assert #region MiseEnPlace var separator = new string('-', 30); const int pad = 20; Approvals.Verify(@$ "Kvitto {separator} {receipt.PrintItems(pad)}{separator} {" Total ",-pad}{total:C} ".Replace("\r", string.Empty)); #endregion }
public IActionResult Get() { var receipt = new Receipt(); receipt.AddCustomerNumber("123"); receipt.AddItem(new Item("Milk", new Amount(CurrencyEnum.EUR, 10.0f))); receipt.AddItem(new Item("Egs", new Amount(CurrencyEnum.EUR, 5.0f))); receipt.AddItem(new Item("Honey", new Amount(CurrencyEnum.EUR, 2.0f))); return(Ok(receipt.ToJson())); }
public void ReceiptHtmlTest() { // Arrange var receipt = new Receipt(); // Act receipt.AddItem("Mjölk", 10.95M, 2); receipt.AddItem("Bröd", 18.5M, 1); receipt.AddItem("Smör", 45.50M, 1); // Assert Approvals.VerifyHtml(receipt.ToHtml()); }
public async void SendReceipt() { // Arrange var receipt = new Receipt(FakeId); receipt.AddItem("Mjölk", 10.95M, 2); receipt.AddItem("Bröd", 18.5M, 1); receipt.AddItem("Smör", 45.50M, 1); // Act await _sut.SendReceiptAsync(receipt, "Test Tester"); // Assert }
public void TestPurchase() { var receipt = new Receipt(); receipt.AddItem(1, "Candy Bar", 0.50); receipt.AddItem(2, "Soda", 1); var expected = @"1 Candy Bar @ $0.50 = $0.50 2 Soda @ $1.00 = $2.00 SubTotal = $2.50 Tax (10%) = $0.25 Total = $2.75"; Assert.AreEqual(expected, receipt.ToString()); }
public void TestPurchase() { var receipt = new Receipt(); receipt.AddItem(1, "Candy Bar", new decimal(0.50)); receipt.AddItem(2, "Soda", 1); var expected = @"1 Candy Bar @ $0.50 = $0.50 2 Soda @ $1.00 = $2.00 SubTotal = $2.50 Tax (10%) = $0.25 Total = $2.75"; receipt.ToString().Should().Be(expected); }
static void Main(string[] args) { Console.WriteLine("Welcome to reciept generator!!! Please enter the number of items which were bought..."); int numOfItems = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter the items line by line..."); Receipt receipt = new Receipt(); try { for (int i = 0; i < numOfItems; i++) { string description = Console.ReadLine(); receipt.AddItem(description); } receipt.CreateReceipt(); string summary = receipt.GenerateReceipt(); Console.WriteLine(summary); } catch (CostMissingException exception) { Console.WriteLine(exception.Message); } catch (ShelfPriceNegetiveException exception) { Console.WriteLine(exception.Message); } }
public ReceiptBuilder WithItem(string text, Action <ReceiptItemBuilder> itemBuilder) { var rib = new ReceiptItemBuilder(text); itemBuilder(rib); r.AddItem(rib.Build()); return(this); }
public void TestGroceries() { var receipt = new Receipt(); receipt.AddItem(1, "Cucumber", 1); receipt.AddItem(2, "2L Cola", 0.89m); receipt.AddItem(5, "Coconut", 1.50m); receipt.AddItem(1, "Punnet cherry tomatoes", 3); receipt.AddItem(5, "Banana", 0.8m); receipt.AddItem(2, "Chicken breast", 1.77m); receipt.AddItem(5, "Tin baked beans", 0.79m); var expected = @"1 Cucumber @ $1.00 = $1.00 2 2L Cola @ $0.89 = $1.78 5 Coconut @ $1.50 = $7.50 1 Punnet cherry tomatoes @ $3.00 = $3.00 5 Banana @ $0.80 = $4.00 2 Chicken breast @ $1.77 = $3.54 5 Tin baked beans @ $0.79 = $3.95 SubTotal = $24.77 Tax (10%) = $2.48 Total = $27.25"; Assert.AreEqual(expected, receipt.ToString()); }
public async Task <CommandResult> Handle(CreateBasicReceiptCommand request, CancellationToken cancellationToken) { var receipt = new Receipt(request.Date, request.CampaignId, request.Description); receipt.AddTags(request.Tags); receipt.AddItem(Receipt.DefaultItemTitle, request.TotalAmount); await _receiptRepository.Add(receipt); return(CommandResult.GetSuccessResult()); }
public void AddItem_Adds_Item_To_List() { // Arrange // Act m_Sut.AddItem(1, "Test", 2.0); // Assert m_List.Received().AddItem(Arg.Is <IReceiptItem>(x => (x.Quantity == 1) && x.ItemDescription.Equals("Test") && (Math.Abs(x.PricePerItem - 2.0d) < Delta))); }
public void Test3() { List <string> descriptions = new List <string>() { "1 imported bottle of perfume at 27.99", "1 bottle of perfume at 18.99", "1 packet of headache pills at 9.75", "1 box of imported chocolates at 11.25" }; string expected = "1 imported bottle of perfume: 32.19\n1 bottle of perfume: 20.89\n1 packet of headache pills: 9.75\n1 imported box of chocolates: 11.85\nSales Taxes: 6.70\nTotal: 74.68"; Receipt receipt = new Receipt(); foreach (string description in descriptions) { receipt.AddItem(description); } receipt.CreateReceipt(); string actual = receipt.GenerateReceipt(); Assert.AreEqual(expected, actual); }
public void Test2() { List <string> descriptions = new List <string>() { "1 book at 12.49", "1 music CD at 14.99", "1 chocolate bar at 0.85" }; string expected = "1 book: 12.49\n1 music CD: 16.49\n1 chocolate bar: 0.85\nSales Taxes: 1.50\nTotal: 29.83"; Receipt receipt = new Receipt(); foreach (string description in descriptions) { receipt.AddItem(description); } receipt.CreateReceipt(); string actual = receipt.GenerateReceipt(); Assert.AreEqual(expected, actual); }
public void Test1() { List <string> descriptions = new List <string>() { "1 imported box of chocolates at 10.00", "1 imported bottle of perfume at 47.50" }; string expected = "1 imported box of chocolates: 10.50\n1 imported bottle of perfume: 54.65\nSales Taxes: 7.65\nTotal: 65.15"; Receipt receipt = new Receipt(); foreach (string description in descriptions) { receipt.AddItem(description); } receipt.CreateReceipt(); string actual = receipt.GenerateReceipt(); Assert.AreEqual(expected, actual); }