示例#1
0
        public void InitClasses()
        {
            ser = new ServiceLayer.ServiceLayer();
            rob = new RobotCellLayer.RobotCellLayer();
            da  = new DataAccess.DataAccess();
            rob.AddRobot("SIM", "SIM");
            logic = new LogicLayer.LogicLayer(ser, rob, da);

            var shelf = new Bottleshelf(10, 0);

            shelf.AddBottle(new Bottle("Vodka"));
            shelf.AddBottle(new Bottle("Vesi"));
            shelf.AddBottle(new Bottle("Mehu"));
            var queue = new OrderQueue();

            var kv = new Drink("Kossuvissy");

            Assert.IsTrue(kv.AddPortion("Vodka", 4));
            Assert.IsTrue(kv.AddPortion("Vesi", 10));

            var mehu = new Drink("Mehu");

            Assert.IsTrue(mehu.AddPortion("Mehu", 10));

            queue.Add(new Tuple <Order, int>(new Order(OrderType.Drink, 1, 1, kv), 10));
            queue.Add(new Tuple <Order, int>(new Order(OrderType.Drink, 2, 4, mehu), 10));
            queue.Add(new Tuple <Order, int>(new Order(OrderType.Drink, 3, 3, kv), 10));
            queue.Add(new Tuple <Order, int>(new Order(OrderType.Drink, 4, 1, kv), 10));

            var startarg = new StartArguments();

            startarg.BackupShelf  = shelf;
            startarg.Mode         = RunMode.Simulation;
            startarg.Beer         = false;
            startarg.Drinks       = true;
            startarg.Sparkling    = false;
            startarg.IdleActivity = new Activity(ActivityType.ProcessOrders);
            startarg.BacckupQueue = queue;

            var init = Task.Run(() => logic.Initialize(startarg, new CancellationToken()));

            init.Wait();
            Assert.IsTrue(init.Result);
        }
示例#2
0
        public void TestOrder()
        {
            var justADrink = new Drink("some");
            var justAOrder = new Order(OrderType.Drink, 1, 1, justADrink);

            Assert.AreEqual(justAOrder.OrderId, 1, "OrderID");
            Assert.AreEqual(justAOrder.GetOrderType(), OrderType.Drink, "Ordertype");
            justADrink.AddPortion(new Portion("a", 3));
            justAOrder = new Order(OrderType.Drink, 2, 1, justADrink);
            Assert.AreEqual(justAOrder.GetRecipe(), justADrink, "Getrecipe");

            justADrink.AddPortion(new Portion("b", 10));
            Assert.IsFalse(justADrink.RemovePortion("c"));
            Assert.AreEqual(justADrink.Portions().Count, 2);
            Assert.IsTrue(justADrink.RemovePortion("b"));
            Assert.AreEqual(justADrink.Portions().Count, 1);
            Assert.IsTrue(justADrink.RemovePortion("a"));
            Assert.AreEqual(justADrink.Portions().Count, 0);
        }
示例#3
0
        private Drink ParseDrink(MessageDataPortion[] msg)
        {
            var result = new Drink("Drink");

            foreach (MessageDataPortion p in msg)
            {
                result.AddPortion(p.DrinkName, p.Volume);
            }
            return(result);
        }