public void AddInvoiceLine_ValidFruit_InvoiceLineIsAdded() { // Arrange var invoices = new List <Invoice>(); var someFruit = new Fruit { Name = "some name", Price = 12 }; var quantity = 2; var fruits = new List <Fruit>() { someFruit }; tillContextMock.SetupGet(m => m.Invoices).Returns(invoices); tillContextMock.SetupGet(m => m.Fruits).Returns(fruits); // Action tillBLut.AddLine(someFruit.Name, quantity.ToString()); // Assert Assert.AreEqual(someFruit.Name, tillBLut.CurrentInvoice.Items.FirstOrDefault().Fruit.Name); Assert.AreEqual(someFruit.Price * quantity, tillBLut.CurrentInvoice.Items.FirstOrDefault().InvoiceRowAmount); }
private void ReadInvoiceLine() { Console.WriteLine("Please enter <quantity> <fruit> desired, or end to finish"); var invoiceLine = Console.ReadLine(); if (invoiceLine != "end") { var ln = invoiceLine.Split(' '); try { TillBL.AddLine(ln[1], ln[0]); } catch (TillBLException e) { Console.WriteLine($"Sorry I didn't understand what you said '{invoiceLine}' because '{e.Message}'"); Console.WriteLine(); } ReadInvoiceLine(); } }