Пример #1
0
        public void ShipFitsTest()
        {
            IBoard board = new Board();
            IShip[] ships = board.ShipsLeftToPlace;

            Assert.IsTrue(board.ShipFits(ships[0], 0, 0, Orientation.Vertical));
            Assert.IsTrue(board.ShipFits(ships[1], 0, 1, Orientation.Vertical));
            Assert.IsTrue(board.ShipFits(ships[2], 0, 2, Orientation.Vertical));
            Assert.IsTrue(board.ShipFits(ships[3], 0, 3, Orientation.Vertical));
            Assert.IsTrue(board.ShipFits(ships[4], 0, 4, Orientation.Vertical));

            Assert.IsTrue(board.ShipFits(ships[0], 0, 0, Orientation.Horizontal));
            Assert.IsTrue(board.ShipFits(ships[1], 0, 1, Orientation.Horizontal));
            Assert.IsTrue(board.ShipFits(ships[2], 0, 2, Orientation.Horizontal));
            Assert.IsTrue(board.ShipFits(ships[3], 0, 3, Orientation.Horizontal));
            Assert.IsTrue(board.ShipFits(ships[4], 0, 4, Orientation.Horizontal));

            board.Place(ships[0], 0, 0, Orientation.Vertical);
            board.Place(ships[1], 0, 1, Orientation.Vertical);
            board.Place(ships[2], 0, 2, Orientation.Vertical);
            board.Place(ships[3], 0, 3, Orientation.Vertical);
            board.Place(ships[4], 0, 4, Orientation.Vertical);

            Assert.IsFalse(board.ShipFits(ships[0], 0, 0, Orientation.Vertical));
            Assert.IsFalse(board.ShipFits(ships[1], 0, 1, Orientation.Vertical));
            Assert.IsFalse(board.ShipFits(ships[2], 0, 2, Orientation.Vertical));
            Assert.IsFalse(board.ShipFits(ships[3], 0, 3, Orientation.Vertical));
            Assert.IsFalse(board.ShipFits(ships[4], 0, 4, Orientation.Vertical));

            Assert.IsFalse(board.ShipFits(ships[0], 0, 0, Orientation.Horizontal));
            Assert.IsFalse(board.ShipFits(ships[1], 1, 0, Orientation.Horizontal));
            Assert.IsFalse(board.ShipFits(ships[2], 2, 0, Orientation.Horizontal));
            Assert.IsFalse(board.ShipFits(ships[3], 3, 0, Orientation.Horizontal));
            Assert.IsFalse(board.ShipFits(ships[4], 4, 0, Orientation.Horizontal));
        }