예제 #1
0
        public async Task <ActionResult <Order> > PostOrder(Order order)
        {
            OrderRules.ProcessRules(order);
            _context.Order.Add(order);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOrder", new { id = order.OrderId }, order));
        }
예제 #2
0
        public void TestFailureOrderContentCommaInvalid()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "bleh,nhjaks"
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("error", order.OrderContents);
        }
예제 #3
0
        public void TestFailureOrderContentNoCommaCase2()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "Night.1;2/3'4"
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("error", order.OrderContents);
        }
예제 #4
0
        public void TestSuccessNightCaseMultipleSides()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "night,1,2,2,3,4"
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("steak, potato(x2), wine, cake", order.OrderContents);
        }
예제 #5
0
        public void TestSuccessMorningCaseMultipleDrinks()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "morning,1,2,3,3"
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("eggs, Toast, coffee(x2)", order.OrderContents);
        }
예제 #6
0
        public void TestFailureOrderContentNull()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = null
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("error", order.OrderContents);
        }
예제 #7
0
        public void TestSuccessMorningCaseBasic()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "Morning,1,2,3"
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("eggs, Toast, coffee", order.OrderContents);
        }
예제 #8
0
        public void TestFailureOrderContentBadMorningOrderMultipleInvalidDessert()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "Morning,1,2,3,4,4"
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("eggs, Toast, coffee, error", order.OrderContents);
        }
예제 #9
0
        public void TestFailureOrderContentBadMorningOrderMultipleInvalidDrink()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "Night,1,2,3,3"
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("steak, potato, wine, error", order.OrderContents);
        }
예제 #10
0
        public void TestFailureOrderContentBadNightOrderMultipleInvalidEntrée()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "Night,1,1,2"
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("steak, error", order.OrderContents);
        }
예제 #11
0
        public void TestSuccessNightCases()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "night,1,2,3,4"
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("steak, potato, wine, cake", order.OrderContents);

            Order order2 = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "Night,1,2,2,4"
            };

            OrderRules.ProcessRules(order2);

            Assert.AreEqual("steak, potato(x2), cake", order2.OrderContents);

            Order order3 = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "NiGhT,1,2,3,5"
            };

            OrderRules.ProcessRules(order3);

            Assert.AreEqual("steak, potato, wine, error", order3.OrderContents);

            Order order4 = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "Night, 1, 1, 2, 3, 5"
            };

            OrderRules.ProcessRules(order4);

            Assert.AreEqual("steak, error", order4.OrderContents);
        }
예제 #12
0
        public void TestSuccessMorningCases()
        {
            Order order = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "MORNING,1,2,3"
            };

            OrderRules.ProcessRules(order);

            Assert.AreEqual("eggs, Toast, coffee", order.OrderContents);

            Order order2 = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "MoRnInG, 2, 1, 3"
            };

            OrderRules.ProcessRules(order2);

            Assert.AreEqual("eggs, Toast, coffee", order2.OrderContents);

            Order order3 = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "morning,1,2,3,4"
            };

            OrderRules.ProcessRules(order3);

            Assert.AreEqual("eggs, Toast, coffee, error", order3.OrderContents);

            Order order4 = new Order
            {
                OrderId       = 0,
                IsMorning     = false,
                OrderContents = "morning,1,2,3,3,3"
            };

            OrderRules.ProcessRules(order4);

            Assert.AreEqual("eggs, Toast, coffee(x3)", order4.OrderContents);
        }