public void MenuBuilder_AddPortion_PortionAdded()
        {
            var menuItem = MenuItemBuilder.Create("Hamburger")
                           .AddPortion("Adet", 5)
                           .Build();

            Assert.AreEqual(1, menuItem.Portions.Count);
        }
        public void MenuItemBuilder_UpdateProductTag_ProductTagAssigned()
        {
            var menuItem = MenuItemBuilder.Create("Tost")
                           .AddPortion("Küçük", 2)
                           .WithProductTag("NoSale")
                           .Build();

            Assert.AreEqual("NoSale", menuItem.Tag);
        }
        public void CanAddOrders()
        {
            var kola   = MenuItemBuilder.Create("Kola").AddPortion("Adet", 5).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do(2)
                         .Build();

            Assert.AreEqual(2, ticket.Orders.Count);
        }
        public void MenuItemBuilder_AddGroupCode_GroupCodeAssigned()
        {
            var menuItem = MenuItemBuilder.Create("Hamburger")
                           .AddPortion("Küçük", 5)
                           .WithGroupCode("İçecekler")
                           .Build();

            Assert.AreEqual("İçecekler", menuItem.GroupCode);
        }
Exemplo n.º 5
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());
        }
        public void MenuBuilder_AddMultiplePortions_PortionCountCorrect()
        {
            var menuItem = MenuItemBuilder.Create("Hamburger")
                           .AddPortion("Küçük", 5)
                           .AddPortion("Büyük", 8)
                           .Build();

            Assert.AreEqual(2, menuItem.Portions.Count);
        }
        public void MergeOrders_OneOrderIsGift_ShouldSkipMerge()
        {
            var kola   = MenuItemBuilder.Create("Kola").AddPortion("Adet", 5).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do(2)
                         .Build();

            ticket.Orders[0].CalculatePrice = false;
            ticket.MergeOrdersAndUpdateOrderNumbers(1);
            Assert.AreEqual(2, ticket.Orders.Count);
        }
        public void MergeOrders_DifferentOrderStates_ShouldSkipMerge()
        {
            var kola   = MenuItemBuilder.Create("Kola").AddPortion("Adet", 5).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do(2)
                         .Build();

            ticket.Orders[0].SetStateValue("Status", 1, "New", 1, "", 0);
            ticket.MergeOrdersAndUpdateOrderNumbers(1);
            Assert.AreEqual(2, ticket.Orders.Count);
        }
        public void CanUpdateQuantityOfMergedOrders()
        {
            var kola   = MenuItemBuilder.Create("Kola").AddPortion("Adet", 5).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do(2)
                         .Build();

            ticket.MergeOrdersAndUpdateOrderNumbers(1);

            Assert.AreEqual(2, ticket.Orders[0].Quantity);
        }
        public void MergeOrders_DifferentOrderQuantites_ShouldSkipMerge()
        {
            var kola   = MenuItemBuilder.Create("Kola").AddPortion("Adet", 5).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).WithQuantity(2).Do()
                         .AddOrder().ForMenuItem(kola).WithQuantity(1).Do()
                         .Build();

            ticket.MergeOrdersAndUpdateOrderNumbers(1);
            Assert.AreEqual(2, ticket.Orders.Count);
        }
        public void OrderMerge_CanCompareOrdersWithDifferentPrice_ReturnsFalse()
        {
            var kola   = MenuItemBuilder.Create("Kola").WithId(1).AddPortion("Adet", 5).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).WithPrice(3).Do()
                         .AddOrder().ForMenuItem(kola).Do()
                         .Build();

            var equals = OrderMerger.CanMergeOrders(ticket.Orders[0], ticket.Orders[1]);

            Assert.False(equals);
        }
        public void MergeOrders_OneOrderPortionDifferent_ShouldSkipMerge()
        {
            var kola   = MenuItemBuilder.Create("Kola").AddPortion("Adet", 5).AddPortion("Büyük", 6).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do(2)
                         .Build();

            ticket.Orders[0].UpdatePortion(kola.Portions[1], "", null);
            ticket.MergeOrdersAndUpdateOrderNumbers(1);
            Assert.AreEqual(2, ticket.Orders.Count);
            Assert.AreEqual(11, ticket.GetSum());
        }
        public void OrderBuilder_CreateMenuItemWithDoublePortions_PriceCorrect()
        {
            var testContext = OrderBuilderTestContext.CreateDefault();
            var tost        = MenuItemBuilder.Create("Tost").AddPortion("Küçük", 4.5m).AddPortion("Büyük", 8).Build();
            var order       = OrderBuilder.Create()
                              .ForMenuItem(tost)
                              .WithPortion(tost.Portions[1])
                              .WithDepartment(testContext.Department)
                              .WithAccountTransactionType(testContext.AccountTransactionType)
                              .Build();

            Assert.AreEqual(8m, order.Price);
        }
        public void CanMergeMultipleOrders()
        {
            var kola   = MenuItemBuilder.Create("Kola").AddPortion("Adet", 5).Build();
            var pizza  = MenuItemBuilder.Create("Pizza").AddPortion("Adet", 10).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do(2)
                         .AddOrder().ForMenuItem(pizza).Do(2)
                         .Build();

            ticket.MergeOrdersAndUpdateOrderNumbers(1);

            Assert.AreEqual(2, ticket.Orders.Count);
        }
        public void OrderMerge_CanCompareOrdersWithOneOfThemGift_ReturnsFalse()
        {
            var kola   = MenuItemBuilder.Create("Kola").WithId(1).AddPortion("Adet", 5).AddPortion("Büyük", 5).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do()
                         .AddOrder().ForMenuItem(kola).Do()
                         .Build();

            ticket.Orders[0].CalculatePrice = false;
            var equals = OrderMerger.CanMergeOrders(ticket.Orders[0], ticket.Orders[1]);

            Assert.False(equals);
        }
        public void OrderMerge_CanCompareOrdersWithDifferentOrderStates_ReturnsFalse()
        {
            var kola   = MenuItemBuilder.Create("Kola").WithId(1).AddPortion("Adet", 5).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do()
                         .AddOrder().ForMenuItem(kola).Do()
                         .Build();

            ticket.Orders[0].SetStateValue("Status", 1, "New", 1, "", 0);
            ticket.Orders[1].SetStateValue("Status", 1, "Submitted", 1, "", 0);
            var equals = OrderMerger.CanMergeOrders(ticket.Orders[0], ticket.Orders[1]);

            Assert.False(equals);
        }
Exemplo n.º 17
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 void MergeMultipleOrders_OneOrderLocked_ShouldSkipMerge()
        {
            var kola   = MenuItemBuilder.Create("Kola").AddPortion("Adet", 5).Build();
            var pizza  = MenuItemBuilder.Create("Pizza").AddPortion("Adet", 10).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do(2)
                         .AddOrder().ForMenuItem(pizza).Do(2)
                         .Build();

            ticket.Orders[0].Locked = true;
            ticket.MergeOrdersAndUpdateOrderNumbers(1);
            Assert.AreEqual(3, ticket.Orders.Count);
            Assert.AreEqual(30, ticket.GetSum());
        }
        public void MergeOrders_OrdersTagged_ShouldSkipMerge()
        {
            var kola   = MenuItemBuilder.Create("Kola").AddPortion("Adet", 5).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do(2)
                         .Build();

            ticket.Orders[0].ToggleOrderTag(new OrderTagGroup {
                Name = "Service"
            }, new OrderTag {
                Name = "Pause"
            }, 0, "");
            ticket.MergeOrdersAndUpdateOrderNumbers(1);
            Assert.AreEqual(2, ticket.Orders.Count);
        }
        public void OrderMerge_CanCompareOrdersWithDifferentOrderTags_ReturnsFalse()
        {
            var kola   = MenuItemBuilder.Create("Kola").WithId(1).AddPortion("Adet", 5).Build();
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrder().ForMenuItem(kola).Do()
                         .AddOrder().ForMenuItem(kola).Do()
                         .Build();

            ticket.Orders[0].ToggleOrderTag(new OrderTagGroup {
                Name = "Service"
            }, new OrderTag {
                Name = "Pause"
            }, 0, "");
            var equals = OrderMerger.CanMergeOrders(ticket.Orders[0], ticket.Orders[1]);

            Assert.False(equals);
        }
Exemplo n.º 21
0
        private static Ticket PrepareTestTicket()
        {
            var hamburger = MenuItemBuilder.Create("Hamburger").WithId(1).WithGroupCode("Food").WithProductTag("Tag1").AddPortion("Small", 5).Build();
            var pizza     = MenuItemBuilder.Create("Pizza").WithId(2).WithGroupCode("Food").WithProductTag("Tag1").AddPortion("Small", 10).Build();
            var cola      = MenuItemBuilder.Create("Coke").WithId(3).WithGroupCode("Drink").AddPortion("Small", 2).Build();

            using (var w = WorkspaceFactory.Create())
            {
                w.Add(hamburger);
                w.Add(pizza);
                w.Add(cola);
            }

            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default)
                         .AddOrderFor(hamburger).Do()
                         .AddOrderFor(pizza).Do()
                         .AddOrderFor(cola).Do()
                         .Build();

            return(ticket);
        }
Exemplo n.º 22
0
 private static MenuItem CreateMenuItem(int id, string name, decimal price)
 {
     return(MenuItemBuilder.Create(name).WithId(id).AddPortion("Portion", price).Build());
 }
        public void MenuBuilder_BuildMenuItem_NameAssigned()
        {
            var menuItem = MenuItemBuilder.Create("Tost").Build();

            Assert.AreEqual("Tost", menuItem.Name);
        }