예제 #1
0
        public void AddBattleShip_AddBattleshipToBoardUntilFull_OK()
        {
            // We don't expect this code to throw exception
            var board = new BattleshipBoard(3);

            Assert.AreEqual(1, board.AddBattleShip(0, 0, 0, 2));
            Assert.AreEqual(2, board.AddBattleShip(1, 0, 2, 0));
            Assert.AreEqual(3, board.AddBattleShip(1, 1, 2, 1));
            Assert.AreEqual(4, board.AddBattleShip(1, 2, 1, 2));
            Assert.AreEqual(5, board.AddBattleShip(2, 2, 2, 2));
            CollectionAssert.AreEqual(
                new int?[][]
            {
                new int?[] { 1, 1, 1 },
                new int?[] { 2, 3, 4 },
                new int?[] { 2, 3, 5 }
            }.SelectMany(x => x).ToArray(),
                board.GetBoardState().SelectMany(x => x).ToArray()
                );
        }