예제 #1
0
        public void Add_AddsAStringToTheReceipt_ContentContainsString()
        {
            var uut = new Receipt();

            uut.AddLine("Test");

            Assert.That(uut.Content, Contains.Item("Test"));
        }
예제 #2
0
        /// <summary>
        /// Formats a new Reciept from an order and prints the Reciept.
        /// </summary>
        /// <param name="order">The Order to be formatted and printed.</param>
        public virtual void CreateReceipt(SalesOrder order)
        {
            var receipt = new Receipt(_formatProvider);

            CreateHeader(receipt, order.Id);

            foreach (var p in order.Lines)
            {
                receipt.AddLine(string.Format(_formatProvider, "{0}x\t{1}\n", p.Quantity, p.Product.Name));
                receipt.AddLine("              ");
                receipt.AddLine(string.Format(_formatProvider, "{0}\n\n", p.UnitPrice));
            }

            receipt.AddLine(string.Format(_formatProvider, "Total: {0}\n\n", order.Total));

            CreateFooter(receipt);

            Print(receipt);
        }
예제 #3
0
 public void Ctor_InitiateReceipt_ContentIsListOfString()
 {
     var uut = new Receipt();
     Assert.That(uut.Content, Is.TypeOf<List<string>>());
 }
예제 #4
0
        /// <summary>
        /// Formats a new Receipt from a Transaction.
        /// </summary>
        /// <param name="transaction">The Transaction to be formatted and printed.</param>
        public virtual void CreateReceipt(Transaction transaction)
        {
            var receipt = new Receipt(_formatProvider);

            receipt.AddLine(string.Format(_formatProvider, "{0}\nDate: {1}\nId: {2}\n{3}\n\b", transaction.PaymentType, transaction.Date, transaction.Id, transaction.Price));

            Print(receipt);
        }
예제 #5
0
        /// <summary>
        /// Prints a Receipt.
        /// </summary>
        /// <param name="receipt">The Receipt to be printed.</param>
        private void Print(Receipt receipt)
        {
            foreach (var line in receipt.Content)
            {
                Printer.AddLine(line);
            }

            Printer.Print();
        }
예제 #6
0
        /// <summary>
        /// Adds the standard header to the Receipt.
        /// </summary>
        /// <param name="receipt">The Receipt that is being formatted.</param>
        /// <param name="orderId">The OrderId from the Order being formatted.</param>
        private void CreateHeader(Receipt receipt, object orderId)
        {
            //var currentDateAndTime = DateTime.Today.ToString("G");

            receipt.AddLine("Katrines Kælder\nFinlandsgade 22\nDK-8200 Aarhus N\n\n");
            receipt.AddLine(string.Format(_formatProvider ,"Dato: {0}\n", DateTime.Today));
            receipt.AddLine(string.Format(_formatProvider, "Ordre id: {0}\n\n", orderId));
            receipt.AddLine("-----\n");
        }
예제 #7
0
 /// <summary>
 /// Adds the standard footer to the Receipt.
 /// </summary>
 /// <param name="receipt">The Receipt that is being formatted.</param>
 private static void CreateFooter(Receipt receipt)
 {
     receipt.AddLine("-----\n");
     receipt.AddLine("På gensyn\n\n");
 }
예제 #8
0
 /// <summary>
 /// Adds the standard footer to the Receipt.
 /// </summary>
 /// <param name="receipt">The Receipt that is being formatted.</param>
 private static void CreateFooter(Receipt receipt)
 {
     receipt.AddLine("-----\n");
     receipt.AddLine("På gensyn\n\n");
 }