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))); } } } } }
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)); }
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))); }
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))); } } }
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"); } } }
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))); } } }