示例#1
0
        public void AddShipVertical_ShouldAddVertically()
        {
            var board      = new Board(10);
            var ship       = ShipFactory.NewDestoryer();
            var coordinate = new Coordinate(3, 3);

            var result = board.AddShip(ship, coordinate, Direction.Vertical);

            var squaresWithShip = board.Squares.Where(x => x.Ship == ship);

            //verify columns are same
            Assert.AreEqual(squaresWithShip.Where(x => x.Coordinate.Column == coordinate.Column).Count(), ship.Length);
            Assert.AreEqual(squaresWithShip.Select(x => x.Coordinate.Row).Distinct().Count(), ship.Length);
        }