Пример #1
0
        public void AddWorkableUnitToQueue()
        {
            UnitFactory lFactory = new UnitFactory(3, 3);

            // Test qu'on peut envoyer des commandes à la volée
            Assert.IsTrue(lFactory.AddWorkableUnitToQueue(typeof(Wall_E), "Machina 1", new Coordinates(), new Coordinates()), "Assert 1");
            Assert.IsTrue(lFactory.AddWorkableUnitToQueue(typeof(R2D2), "Machina 2", new Coordinates(), new Coordinates()), "Assert 2");
            Assert.IsTrue(lFactory.AddWorkableUnitToQueue(typeof(T_800), "Machina 3", new Coordinates(), new Coordinates()), "Assert 3");

            // Test de la réponse quand la queue est pleine
            Assert.IsFalse(lFactory.AddWorkableUnitToQueue(typeof(Wall_E), "Machina 4", new Coordinates(), new Coordinates()), "Assert 4");

            //On attend la construction du premier robot pour déposer une nouvelle demande
            Thread.Sleep(10000);
            // Si une place se libère, on doit pouvoir créer une nouvelle commmande etc...
            Assert.IsTrue(lFactory.AddWorkableUnitToQueue(typeof(HAL), "Machina 5", new Coordinates(), new Coordinates()), "Assert 5");
            Thread.Sleep(10000);
            Assert.IsTrue(lFactory.AddWorkableUnitToQueue(typeof(R2D2), "Machina 6", new Coordinates(), new Coordinates()), "Assert 6");
            Thread.Sleep(10000);
            Assert.IsTrue(lFactory.AddWorkableUnitToQueue(typeof(T_800), "Machina 6", new Coordinates(), new Coordinates()), "Assert 7");
            Thread.Sleep(10000);
            Assert.IsTrue(lFactory.AddWorkableUnitToQueue(typeof(R2D2), "Machina 6", new Coordinates(), new Coordinates()), "Assert 8");

            // On teste que l'on ne puisse plus envoyer de demandes quand les deux files sont pleines
            Thread.Sleep(10000);
            Assert.IsFalse(lFactory.AddWorkableUnitToQueue(typeof(T_800), "Machina 6", new Coordinates(), new Coordinates()), "Assert 9");
        }
Пример #2
0
        static void Main(string[] args)
        {
            int QueueCapacity   = 10;
            int StorageCapacity = 15;

            HAL    hal01   = new HAL(0.5, 7, "hal01", new Coordinates(0, 0), new Coordinates(5, 5));
            R2D2   r2d201  = new R2D2(1.5, 5.5, "r2d201", new Coordinates(0, 0), new Coordinates(5, 5));
            T_800  t80001  = new T_800(3, 10, "t80001", new Coordinates(0, 0), new Coordinates(5, 5));
            Wall_E walle01 = new Wall_E(2, 4, "walle01", new Coordinates(0, 0), new Coordinates(5, 5));

            UnitFactory unitFactory = new UnitFactory(QueueCapacity, StorageCapacity);

            unitFactory.AddWorkableUnitToQueue(hal01.GetType(), hal01.Name, hal01.parkingPos, hal01.workingPos);
            unitFactory.AddWorkableUnitToQueue(r2d201.GetType(), r2d201.Name, r2d201.parkingPos, r2d201.workingPos);
            unitFactory.AddWorkableUnitToQueue(t80001.GetType(), t80001.Name, hal01.parkingPos, t80001.workingPos);
            unitFactory.AddWorkableUnitToQueue(walle01.GetType(), walle01.Name, walle01.parkingPos, walle01.workingPos);
        }
Пример #3
0
        static void Main(string[] args)
        {
            bool        t       = true;
            UnitFactory factory = new UnitFactory(7, 7);

            factory.AddWorkableUnitToQueue((new R2D2()).GetType(), "R2D2", new Coordinates(3, 3), new Coordinates(6, 6));
            while (t == true)
            {
                factory.createRobot();
                if (factory.Queue.Count() <= factory.QueueCapacity)
                {
                    factory.AddWorkableUnitToQueue((new R2D2()).GetType(), "R2D2", new Coordinates(3, 3), new Coordinates(6, 6));
                }
                if (factory.Queue.Count() >= factory.QueueCapacity && factory.Storage.Count >= factory.StorageCapacity)
                {
                    t = false;
                }
            }

            /*BaseUnit t = new TestClasse("Toto", 2);
             * t.Move( new Common.Tools.Coordinates( 2, 2 ));
             * t.DoSomethingElse();*/
        }
Пример #4
0
        static void Main(string[] args)
        {
            Coordinates parkingPos = new Coordinates()
            {
                X = 0, Y = 0
            };
            Coordinates workingPos = new Coordinates()
            {
                X = 5, Y = 5
            };
            IUnitFactory unitFactory = new UnitFactory(5, 10);

            unitFactory.FactoryStatus += UnitFactory_FactoryStatus;
            unitFactory.AddWorkableUnitToQueue(typeof(T_800), "R1", parkingPos, workingPos);
        }
Пример #5
0
        public void AddWorkableUnitToQueue_avecMockA1etMockB1_RetourneTrue()
        {
            bool result = unitFactory.AddWorkableUnitToQueue(typeof(R2D2), "R2D2 unit", currentPos, new Coordinates(1, 1));

            Assert.IsTrue(result);
        }