Exemple #1
0
        public void TicketBuilder_CreatesDefaultTicket_CreatesAccountTransactionDocument()
        {
            var context = TicketBuilderTestContext.GetDefaultContext();
            var ticket  = TicketBuilder.Create(context.TicketType, context.Department).Build();

            Assert.IsNotNull(ticket.TransactionDocument);
        }
Exemple #2
0
        public void TicketBuilder_CreatesTicketWithDepartment_DepartmentAssigned()
        {
            var context = TicketBuilderTestContext.GetDefaultContext();
            var ticket  = TicketBuilder.Create(context.TicketType, context.Department).Build();

            Assert.AreEqual(1, ticket.DepartmentId);
        }
Exemple #3
0
        public void TicketBuilder_CreatesDefaultTicket_IsDefaultExchangeRate()
        {
            var context = TicketBuilderTestContext.GetDefaultContext();
            var ticket  = TicketBuilder.Create(context.TicketType, context.Department).Build();

            Assert.AreEqual(1, ticket.ExchangeRate);
        }
Exemple #4
0
        public void TicketBuilder_CreatesTaxExcludedTicket_IsTaxExcluded()
        {
            var context = TicketBuilderTestContext.GetDefaultContext().WithTicketTypeTaxIsExcluded();
            var ticket  = TicketBuilder.Create(context.TicketType, context.Department).Build();

            Assert.False(ticket.TaxIncluded);
        }
Exemple #5
0
        public void TicketBuilder_CreatesDefaultTicket_TicketTypeIdAssigned()
        {
            var context = TicketBuilderTestContext.GetDefaultContext();
            var ticket  = TicketBuilder.Create(context.TicketType, context.Department).Build();

            Assert.AreEqual(context.TicketType.Id, ticket.TicketTypeId);
        }
Exemple #6
0
        public void TicketBuilder_CreatesOrder_OrderAdded()
        {
            var context = TicketBuilderTestContext.GetDefaultContext();
            var ticket  = TicketBuilder.Create(context.TicketType, context.Department)
                          .AddOrder().ForMenuItem(MenuItemBuilder.Create("Hamburger").AddPortion("Adet", 10).Build()).Do()
                          .Build();

            Assert.AreEqual(10, ticket.GetSum());
        }
Exemple #7
0
        public void TicketBuilder_CreatesTicketWithCalculations_DiscountAdded()
        {
            var context = TicketBuilderTestContext.GetDefaultContext().With10PercentDiscount();
            var ticket  = TicketBuilder.Create(context.TicketType, context.Department)
                          .WithCalculations(context.Calculations)
                          .Build();

            Assert.AreEqual(10, ticket.Calculations.Sum(x => x.Amount));
        }
Exemple #8
0
        public void TicketBuilder_CreatesTicketWithExchangeRate_ExchangeRateAssigned()
        {
            var context = TicketBuilderTestContext.GetDefaultContext();
            var ticket  = TicketBuilder.Create(context.TicketType, context.Department)
                          .WithExchangeRate(1.1m)
                          .Build();

            Assert.AreEqual(1.1m, ticket.ExchangeRate);
        }
Exemple #9
0
        public static TicketBuilderTestContext GetDefaultContext()
        {
            var result = new TicketBuilderTestContext();

            result.TicketType = new TicketType {
                Id = 1, SaleTransactionType = AccountTransactionType.Default
            };
            result.Department = new Department {
                Id = 1
            };
            return(result);
        }
Exemple #10
0
        public void TicketBuilder_AddsOrderWithMultipleMenuItems_OrdersAdded2()
        {
            var context = TicketBuilderTestContext.GetDefaultContext();

            var hamburger = MenuItemBuilder.Create("Hamburger").AddPortion("Adet", 10).Build();
            var tost      = MenuItemBuilder.Create("Tost").AddPortion("Adet", 4).Build();

            var ticket = TicketBuilder.Create(context.TicketType, context.Department)
                         .AddOrderFor(hamburger).Do()
                         .AddOrderFor(tost).WithQuantity(2).Do()
                         .Build();

            Assert.AreEqual(10 + (4 * 2), ticket.GetSum());
        }
 public static TicketBuilderTestContext GetDefaultContext()
 {
     var result = new TicketBuilderTestContext();
     result.TicketType = new TicketType { Id = 1, SaleTransactionType = AccountTransactionType.Default };
     result.Department = new Department { Id = 1 };
     return result;
 }