예제 #1
0
        public void TestMultipleOrderCoffee()
        {
            var input = new[] { new { TypeId = 1 }, new { TypeId = 2 }, new { TypeId = 3 }, new { TypeId = 3 }, new { TypeId = 3 } }.ToList();

            var timeofday = "morning";

            var rs = input.GroupJoin(dishes, o => new { o.TypeId, TimeofDay = timeofday }, d => new { d.TypeId, d.TimeofDay },
                (o, d) => new Order { TypeId = o.TypeId, Dish = d.DefaultIfEmpty().FirstOrDefault() }).
                        OrderBy(t => t.TypeId).ToList<Order>();

             Assert.IsTrue(TestRules(new MultipleOrder(rs),5));
        }
예제 #2
0
        public void TestOrdersError()
        {
            var input = new[] { new { TypeId = 1 }, new { TypeId = 1 }, new { TypeId = 2 }, new { TypeId = 3 }, new { TypeId = 5} }.ToList();

            var timeofday = "night";

            var rs = input.GroupJoin(dishes, o => new { o.TypeId, TimeofDay = timeofday }, d => new { d.TypeId, d.TimeofDay },
                (o, d) => new Order { TypeId = o.TypeId, Dish = d.DefaultIfEmpty().FirstOrDefault() }).
                        OrderBy(t => t.TypeId).ToList<Order>();

            IRule[] rules = { new MultipleOrder(rs) };

            ILogic logic = new Logic(rs, rules);

            Assert.AreEqual(logic.Execute(), "steak, error");
        }
예제 #3
0
        public void TestOrders213()
        {
            var input = new[] { new { TypeId = 2 }, new { TypeId = 1 }, new { TypeId = 3 } }.ToList();

            var timeofday = "morning";

            var rs = input.GroupJoin(dishes, o => new { o.TypeId, TimeofDay = timeofday }, d => new { d.TypeId, d.TimeofDay },
                (o, d) => new Order { TypeId = o.TypeId, Dish = d.DefaultIfEmpty().FirstOrDefault() }).
                        OrderBy(t => t.TypeId).ToList<Order>();

            IRule[] rules = { };

            ILogic logic = new Logic(rs, rules);

            Assert.AreEqual(logic.Execute(), "eggs, toast, coffee");
        }
예제 #4
0
        public void TestNoErrorsRepeatPotato()
        {
            var input = new[] { new { TypeId = 1 }, new { TypeId = 2 }, new { TypeId = 2 }, new { TypeId = 4 }}.ToList();

            var timeofday = "night";

            var rs = input.GroupJoin(dishes, o => new { o.TypeId, TimeofDay = timeofday }, d => new { d.TypeId, d.TimeofDay },
                (o, d) => new Order { TypeId = o.TypeId, Dish = d.DefaultIfEmpty().FirstOrDefault() }).
                        OrderBy(t => t.TypeId).ToList<Order>();

            Assert.IsTrue(TestRules(new MultipleOrder(rs), 4));
        }