public void CheckoutTable_succeeds_for_bartender_and_waiter()
        {
            var orders = new List <OrderItem>()
            {
                new OrderItem()
                {
                    Table = 1, Quantity = 3
                },
                new OrderItem()
                {
                    Table = 2, Quantity = 2
                }
            };

            var mockContext = new MockDBContextFactory().WithBuiltinOrderItems(orders).Create();

            var repository = new RestourantRepository(mockContext);

            repository.CheckoutTable(1, EmployeeRole.BARTENDER);

            Assert.IsTrue(orders[0].Payed);
            Assert.IsFalse(orders[1].Payed);

            orders[0].Payed = false;

            repository.CheckoutTable(2, EmployeeRole.WAITER);

            Assert.IsFalse(orders[0].Payed);
            Assert.IsTrue(orders[1].Payed);
        }
        public void CheckoutTable_failes_when_no_orders_for_table()
        {
            var mockContext = new MockDBContextFactory().Create();
            var repository  = new RestourantRepository(mockContext);

            repository.CheckoutTable(1, EmployeeRole.BARTENDER);
        }
        public void CheckoutTable_failes_when_worker_is_cook()
        {
            var mockContext = new MockDBContextFactory().Create();

            var repository = new RestourantRepository(mockContext);

            repository.CheckoutTable(1, EmployeeRole.COOK);
        }
        public void CheckoutTable_calls_save_changes()
        {
            var orders = new List <OrderItem>(0)
            {
                new OrderItem()
                {
                    Table    = 2,
                    Quantity = 10
                }
            };

            var numSaveCalls = 0;

            var mockContext = new MockDBContextFactory().WithBuiltinOrderItems(orders).WithSaveChangesCallback(() => ++ numSaveCalls).Create();

            var repository = new RestourantRepository(mockContext);

            repository.CheckoutTable(2, EmployeeRole.BARTENDER);

            Assert.AreEqual(1, numSaveCalls);
        }