Exemple #1
0
        public void AddCustomer()
        {
            // Arrange
            var data = new[] { new Coffee("Espresso"), new Coffee("Espresso"), new Coffee("Royal"), new Coffee("Royal"), new Coffee("Espresso"), new Coffee("Tasty"), new Coffee("Mocha"), };
            var sut  = new CoffeeShop(data, 4);

            // Act
            sut.AddCustomer();
            Assert.IsTrue(sut.CustomersInQueue.Count == 5);
            sut.AddCustomer();
            // Assert
            Assert.IsTrue(data.GroupBy(x => x).All(x => x.Count() == data.Count(c => c.Equals(x.First()))));
            Assert.IsTrue(sut.CustomersInQueue.Count == 6);
            Assert.IsTrue(sut.NextTicket == 7);
            Assert.IsTrue(sut.NextTicket == 7);
        }
Exemple #2
0
        private ICoffeeShop GivenCoffeeShopWithCustomers()
        {
            Mock.Get(_coffeeStrategyFactory).Setup(s => s.CreateCoffeeContext(It.IsAny <CustomerType>())).Returns(_customerCoffeeContext);
            Mock.Get(_coffeeShopReportGenerator).Setup(s => s.GenerateSummaryReport(It.IsAny <ICoffeeShopState>())).Returns("My coffee shop summary");

            var coffeeShop = new CoffeeShop(_coffeeShopReportGenerator, _coffeeStrategyFactory, _coffeeShopState);

            coffeeShop.AddCustomer(new Customer
            {
                Name   = "Christopher",
                Type   = CustomerType.General,
                Drinks = new List <Drink>
                {
                    new Drink("Americano")
                    {
                        BaseCost = 50, BasePrice = 100, LoyaltyPointsGained = 5
                    }
                }
            });

            coffeeShop.AddCustomer(new Customer
            {
                Name                 = "Kirsty",
                Type                 = CustomerType.LoyaltyMember,
                LoyaltyPoints        = 60,
                IsUsingLoyaltyPoints = false,
                Drinks               = new List <Drink> {
                    new Drink("Latte")
                    {
                        BaseCost = 50, BasePrice = 100, LoyaltyPointsGained = 5
                    },
                    new Drink("Espresso")
                    {
                        BaseCost = 30, BasePrice = 60, LoyaltyPointsGained = 3
                    }
                }
            });

            return(coffeeShop);
        }
        private static ICoffeeShop GivenCoffeeShop()
        {
            ICoffeeShop coffeeShop = new CoffeeShop(new CoffeeShopReportGenerator(), new CoffeeStrategyFactory(), new CoffeeShopState());

            coffeeShop.AddCustomer(new Customer
            {
                Name   = "Christopher",
                Type   = CustomerType.General,
                Drinks = new List <Drink>
                {
                    new Drink("Americano")
                    {
                        BaseCost = 50, BasePrice = 100, LoyaltyPointsGained = 5
                    }
                }
            });

            coffeeShop.AddCustomer(new Customer
            {
                Name                 = "Damian",
                Type                 = CustomerType.LoyaltyMember,
                LoyaltyPoints        = 1000,
                IsUsingLoyaltyPoints = true,
                Drinks               = new List <Drink>
                {
                    new Drink("Cappuccino")
                    {
                        BaseCost = 60, BasePrice = 120, LoyaltyPointsGained = 8
                    }
                }
            });

            coffeeShop.AddCustomer(new Customer
            {
                Name                 = "Kirsty",
                Type                 = CustomerType.LoyaltyMember,
                LoyaltyPoints        = 60,
                IsUsingLoyaltyPoints = false,
                Drinks               = new List <Drink> {
                    new Drink("Latte")
                    {
                        BaseCost = 50, BasePrice = 100, LoyaltyPointsGained = 5
                    },
                    new Drink("Espresso")
                    {
                        BaseCost = 30, BasePrice = 60, LoyaltyPointsGained = 3
                    }
                }
            });

            coffeeShop.AddCustomer(new Customer
            {
                Name   = "Andrzej",
                Type   = CustomerType.CoffeeEmployee,
                Drinks = new List <Drink>
                {
                    new Drink("Americano")
                    {
                        BaseCost = 50, BasePrice = 100, LoyaltyPointsGained = 5
                    }
                }
            });

            coffeeShop.AddCustomer(new Customer
            {
                Name   = "Matt",
                Type   = CustomerType.DiscountMember,
                Drinks = new List <Drink>
                {
                    new Drink("Mocha")
                    {
                        BaseCost = 60, BasePrice = 120, LoyaltyPointsGained = 8
                    }
                }
            });

            return(coffeeShop);
        }