Ejemplo n.º 1
0
        public void Add_AddsAStringToTheReceipt_ContentContainsString()
        {
            var uut = new Receipt();

            uut.AddLine("Test");

            Assert.That(uut.Content, Contains.Item("Test"));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 public void Ctor_InitiateReceipt_ContentIsListOfString()
 {
     var uut = new Receipt();
     Assert.That(uut.Content, Is.TypeOf<List<string>>());
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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");
        }
Ejemplo 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");
 }
Ejemplo 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");
 }