Пример #1
0
        public void Manager_Simple_Run()
        {
            //Arrange
            string   name    = "Barry";
            Type     gender  = typeof(Drone);
            IManager manager = new SimpleManager
            {
                Animals = new List <IAnimal>
                {
                    new Bee(name, (IGender)Activator.CreateInstance(gender), 1)
                }
            };

            //Act
            manager.Run();

            //Assert
            Assert.AreEqual(gender, manager.Animals[0].Gender.GetType());
            Assert.AreEqual(typeof(Queen), manager.Animals[1].Gender.GetType());
        }
Пример #2
0
        public void Bee_Pattern_Run()
        {
            //Arrange
            //Create animal number pattern
            IManager manager = new SimpleManager
            {
                Animals = new List <IAnimal>
                {
                    new Bee("Bee0", new Drone(), 1)
                }
            };

            //Act
            manager.Run();
            List <int> pattern = new List <int>(Quantification.CountGenerations(manager));

            //Assert
            for (int patternCnt = 1; patternCnt <= manager.NumberOfGenerations; patternCnt++)
            {
                Assert.AreEqual((int)Gensim.Helpers.Math.Fibonacci(patternCnt), pattern[patternCnt - 1]);
            }
        }
Пример #3
0
        public void Human_Pattern_Run()
        {
            //Arrange
            //Create animal number pattern
            IManager manager = new SimpleManager
            {
                Animals = new List <IAnimal>
                {
                    new Human("Human0", new Man(), 1)
                }
            };

            //Act
            manager.Run();
            List <int> pattern = new List <int>(Quantification.CountGenerations(manager));

            //Assert
            for (int patternCnt = 0; patternCnt < manager.NumberOfGenerations; patternCnt++)
            {
                Assert.AreEqual((int)System.Math.Pow(2, patternCnt), pattern[patternCnt]);
            }
        }