예제 #1
0
        public void BuildTest()
        {
            var frequency = 10;
            var eatMatrix = new FoodMatrix(2, 2, new FillingOfEntireFieldStrategy(frequency));
            var creatures = new bool[2, 2];

            for (int k = 0; k < 10; k++)
            {
                if (k != 9 && FoodMatrixConstants.AddedFoodLevel <= FoodMatrixConstants.MaxFoodLevel)
                {
                    eatMatrix.Build(creatures);
                    for (int i = 0; i < eatMatrix.Length; i++)
                    {
                        for (int j = 0; j < eatMatrix.Height; j++)
                        {
                            Assert.IsFalse(eatMatrix.HasMaxFoodLevel(new Point(i, j)));
                        }
                    }
                }

                if (k == 9)
                {
                    FrequentlyUsedMethods.RaiseFoodLevelToConstantWithBuild(eatMatrix, creatures, FoodMatrixConstants.MaxFoodLevel, frequency);
                    for (int i = 0; i < eatMatrix.Length; i++)
                    {
                        for (int j = 0; j < eatMatrix.Height; j++)
                        {
                            Assert.IsTrue(eatMatrix.HasMaxFoodLevel(new Point(i, j)));
                        }
                    }
                }
            }
        }
예제 #2
0
        public void HasMaxFoodLevelIsTrueTest()
        {
            var eatMatrix = new FoodMatrix(2, 2, new FillingFromCornersByWavesStrategy());
            var point = new Point(0, 0);

            FrequentlyUsedMethods.RaiseFoodLevelToConstantWithAddFood(eatMatrix, point, FoodMatrixConstants.MaxFoodLevel);

            Assert.IsTrue(eatMatrix.HasMaxFoodLevel(point));
        }
예제 #3
0
        public void HasMaxFoodLevelIsTrueTest()
        {
            var eatMatrix = new FoodMatrix(2, 2, new FillingFromCornersByWavesStrategy());
            var point     = new Point(0, 0);

            FrequentlyUsedMethods.RaiseFoodLevelToConstantWithAddFood(eatMatrix, point, FoodMatrixConstants.MaxFoodLevel);

            Assert.IsTrue(eatMatrix.HasMaxFoodLevel(point));
        }
예제 #4
0
        public void BuildWithOneFreeCellTest()
        {
            var eatMatrix = new FoodMatrix(2, 2, new FillingFromCornersByWavesStrategy());
            var creatures = new bool[2, 2];

            creatures[0, 0] = true;
            creatures[0, 1] = true;
            creatures[1, 0] = true;

            FrequentlyUsedMethods.RaiseFoodLevelToConstantWithBuild(eatMatrix, creatures, FoodMatrixConstants.MaxFoodLevel, 1);
            Assert.IsTrue(eatMatrix.HasMaxFoodLevel(new Point(1, 1)));
        }
예제 #5
0
        public void HasMaxFoodLevelIsFalseTest()
        {
            var eatMatrix = new FoodMatrix(2, 2, new FillingFromCornersByWavesStrategy());

            for (int i = 0; i < eatMatrix.Length; i++)
            {
                for (int j = 0; j < eatMatrix.Height; j++)
                {
                    if (FoodMatrixConstants.AddedFoodLevel < FoodMatrixConstants.MaxFoodLevel)
                        eatMatrix.AddFood(new Point(i, j));
                    Assert.IsFalse(eatMatrix.HasMaxFoodLevel(new Point(i, j)));
                }
            }
        }
예제 #6
0
        public void BuildIsFullTest()
        {
            var eatMatrix = new FoodMatrix(2, 2, new FillingFromCornersByWavesStrategy());
            var creatures = new bool[2, 2];

            eatMatrix.Build(creatures);
            for (int i = 0; i < eatMatrix.Length; i++)
            {
                for (int j = 0; j < eatMatrix.Height; j++)
                {
                    Assert.IsTrue(eatMatrix.HasMaxFoodLevel(new Point(i, j)), "Your MaxFoodLevel constant exceeds AddedFoodLevel multiplied by 4");
                }
            }
        }
예제 #7
0
        public void HasMaxFoodLevelIsFalseTest()
        {
            var eatMatrix = new FoodMatrix(2, 2, new FillingFromCornersByWavesStrategy());

            for (int i = 0; i < eatMatrix.Length; i++)
            {
                for (int j = 0; j < eatMatrix.Height; j++)
                {
                    if (FoodMatrixConstants.AddedFoodLevel < FoodMatrixConstants.MaxFoodLevel)
                    {
                        eatMatrix.AddFood(new Point(i, j));
                    }
                    Assert.IsFalse(eatMatrix.HasMaxFoodLevel(new Point(i, j)));
                }
            }
        }