コード例 #1
0
        public void PassingMatrixToFillMethodShouldNotThrowException()
        {
            var mock = new Mock<IFiller>();
            var matrix = new Balloon[6, 6];
            mock.Setup(f => f.Fill(new Balloon[5, 5])).Verifiable();

            var filler = mock.Object;
            filler.Fill(matrix);
        }
コード例 #2
0
        public void PassingEmptyMatrixToFillMethodShouldNotBeEmptyAfterThat()
        {
            var matrix = new Balloon[5, 5];
            var filler = new Filler(new BalloonsFactory());

            filler.Fill(matrix);

            Assert.IsNotNull(matrix[1, 1]);
        }
コード例 #3
0
        public void ManagerSaveMethodShouldCallGameFieldSaveFieldMethod()
        {
            var matrix = new Balloon[2, 2];
            var mockField = new Mock<IGameField>();
            mockField.Setup(f => f.SaveField()).Returns(new FieldMemory(matrix));

            var manager = new FieldMemoryManager();

            var field = mockField.Object;
            manager.Save(field);
        }
コード例 #4
0
        public void GetMementoShouldReturnEmplpyMatrixWhenSuchPassed()
        {
            var matrix = new Balloon[2, 2];
            var memory = new FieldMemory(matrix);
            var savedMatrix = memory.GetMemento();

            var expectedResult = true;
            for (int i = 0; i < savedMatrix.GetLength(0); i++)
            {
                for (int j = 0; j < savedMatrix.GetLength(1); j++)
                {
                    if (savedMatrix[i, i] != null)
                    {
                        expectedResult = false;
                    }
                }
            }

            Assert.IsTrue(expectedResult);
        }
コード例 #5
0
        public void Fill(Balloon[,] field)
        {
            if (field == null)
            {
                throw new ArgumentNullException(FieldNullErrorMessage);
            }

            int rows = field.GetLength(0);
            int columns = field.GetLength(1);

            for (int row = 0; row < rows; row++)
            {
                for (int column = 0; column < columns; column++)
                {
                    string randomSymbol = RandomProvider.GetRandomNumber(1, 5).ToString();

                    field[row, column] = this.balloonsFactory.GetBalloon(randomSymbol);
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldMemory"/> class.
 /// </summary>
 /// <param name="fieldMatrix">Field which has to be saved.</param>
 public FieldMemory(Balloon[,] fieldMatrix)
 {
     this.fieldMatrix = fieldMatrix;
 }