public GridSquareArrayBuilder WithStatus(GridSquareStatus status)
 {
     for (int i = 0; i < _gridSquareMocks.Length; i++)
     {
         _gridSquareMocks[i] = new GridSquareBuilder().WithStatus(status).BuildMock();
     }
     return this;
 }
 public GridSquareArrayBuilder(ShipKind kind)
 {
     _gridSquareMocks = new Mock<IGridSquare>[kind.Size];
     for (int i = 0; i < kind.Size; i++)
     {
         _gridSquareMocks[i] = new GridSquareBuilder().BuildMock();
     }
 }
示例#3
0
        public GridBuilder(int size = 10)
        {
            _size     = size;
            _gridMock = new Mock <IGrid>();
            _gridMock.SetupGet(g => g.Size).Returns(size);

            _squareBuilders = new GridSquareBuilder[size, size];
            _squares        = new IGridSquare[size, size];

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    _squareBuilders[i, j] = new GridSquareBuilder(new GridCoordinate(i, j));
                    _squares[i, j]        = _squareBuilders[i, j].Build();
                }
            }

            _gridMock.SetupGet(g => g.Squares).Returns(_squares);
            _gridMock.Setup(g => g.GetSquareAt(It.IsAny <GridCoordinate>())).Returns((GridCoordinate coordinate) =>
                                                                                     _squares[coordinate.Row, coordinate.Column]);
        }