public void FulfillOrder_succeeds_for_bartender_and_waiter_and_calls_save_changes()
        {
            var orders = new List <OrderItem>();

            orders.Add(new OrderItem()
            {
                ID        = 1,
                Delivered = false,
                Item      = null,
                Quantity  = 1
            });

            var numSaveCalls = 0;

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

            var repository = new RestourantRepository(mockContext);

            repository.FulfillOrder(orders[0].ID, EmployeeRole.BARTENDER);

            Assert.IsTrue(orders[0].Delivered);
            Assert.AreEqual(1, numSaveCalls);

            numSaveCalls        = 0;
            orders[0].Delivered = false;

            repository.FulfillOrder(orders[0].ID, EmployeeRole.WAITER);

            Assert.IsTrue(orders[0].Delivered);
            Assert.AreEqual(1, numSaveCalls);
        }
        public void FulfillOrder_failes_when_invalid_order_id_specified()
        {
            var orders = new List <OrderItem>();

            orders.Add(new OrderItem()
            {
                ID        = 1,
                Delivered = true,
                Item      = null,
                Quantity  = 1
            });

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

            var repository = new RestourantRepository(mockContext);

            repository.FulfillOrder(15, EmployeeRole.WAITER);
        }
        public void FulfillOrder_failes_when_worker_is_cook()
        {
            var orders = new List <OrderItem>();

            orders.Add(new OrderItem()
            {
                ID        = 1,
                Delivered = false,
                Item      = null,
                Quantity  = 1
            });

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

            var repository = new RestourantRepository(mockContext);

            repository.FulfillOrder(orders[0].ID, EmployeeRole.COOK);
        }