示例#1
0
        public void DecrementOrder()
        {
            var    service     = new Lunch.Order.OrderService();
            string person      = "Mini";
            string description = "fries";

            Action restoreAmount = () => service.Order(description, person, 5);

            {
                restoreAmount();
                OrderResult result = service.DecrementOrder(description, person);
                Assert.True(result.Successful);
                Assert.Equal(4, result.OrderItem.Amount);
            }

            {
                restoreAmount();
                OrderResult result = service.DecrementOrder(description, person, 2);
                Assert.True(result.Successful);
                Assert.Equal(3, result.OrderItem.Amount);
            }

            {
                restoreAmount();
                service.DecrementOrder(description, person);
                OrderResult result = service.DecrementOrder(description, person, 2);
                Assert.True(result.Successful);
                Assert.Equal(2, result.OrderItem.Amount);
            }

            // the rest of the tests are int Order()
        }
示例#2
0
        public void GetItemsByPerson()
        {
            var    service = new Lunch.Order.OrderService();
            string person  = "Mini";

            Assert.Empty(service.GetItems(person));

            service.Order("fries", person, 1);
            Assert.NotEmpty(service.GetItems(person));
        }
示例#3
0
        public void Order()
        {
            var    service     = new Lunch.Order.OrderService();
            string person      = "Mini";
            string description = "fries";

            {
                OrderResult result = service.Order(description, person, 1);
                Assert.True(result.Successful);
            }

            {
                OrderResult result = service.Order(description, person, 2);
                Assert.True(result.Successful);
                Assert.Equal(2, result.OrderItem.Amount);
            }

            {
                OrderResult result = service.Order(description, person, -1);
                Assert.False(result.Successful);
                Assert.Equal(OrderException.NewAmountLowerThanZero, result.Exception);
            }

            {
                OrderResult result = service.Order("aint got this item", person, 1);
                Assert.False(result.Successful);
                Assert.Equal(OrderException.MenuItemDoesNotExist, result.Exception);
            }

            {
                OrderResult result = service.Order(null, person, 1);
                Assert.False(result.Successful);
                Assert.Equal(OrderException.MenuItemDoesNotExist, result.Exception);
            }

            {
                OrderResult result = service.Order(description, null, 1);
                Assert.False(result.Successful);
                Assert.Equal(OrderException.PersonNotProvided, result.Exception);
            }
        }