예제 #1
0
        public static IEnumerable <object[]> Can_detect_when_a_column_is_full_TestData()
        {
            return(new List <object[]>
            {
                new object[]
                {
                    BoardGridHelper.CreateFourByFourBoard(), 1, false
                },

                new object[]
                {
                    BoardGridHelper.CreateFourByFourBoard(), 2, false
                },

                new object[]
                {
                    BoardGridHelper.CreateFourByFourBoard(), 3, true
                },

                new object[]
                {
                    BoardGridHelper.CreateFourByFourBoard(), 4, false
                },
            });
        }
예제 #2
0
        public void Throws_ColumnDoesntExistFullException_when_trying_to_add_to_a_column_that_does_not_exist(int columnIndex)
        {
            var sut       = BoardGridHelper.CreateFourByFourBoard();
            var exception = Assert.Throws <ColumnDoesntExistException>(
                () => sut.DropValueIntoColumn(BoardSlotValue.P1, columnIndex)
                );

            Assert.Equal(columnIndex, exception.ColumnIndex);
        }
예제 #3
0
        public void Throws_BoardIsFullException_when_trying_to_add_to_a_full_board(int columnIndex)
        {
            var sut = BoardGridHelper.CreateFullBoard();

            var exception = Assert.Throws <BoardIsFullException>(
                () => sut.DropValueIntoColumn(BoardSlotValue.P1, columnIndex)
                );

            Assert.Equal("Board is full.", exception.Message);
        }
예제 #4
0
 public static IEnumerable <object[]> Can_detect_draw_TestData()
 => BoardGridHelper
 .CreateWinningBoardGridForPlayerOne()
 .Boards
 .Where(x => x.WinMethod == WinMethod.Draw)
 .Select(x => new object[]
 {
     x.Board,
     new WinState(x.WinMethod),
 });
예제 #5
0
        public void Throws_ColumnIsFullException_when_trying_to_add_to_a_full_column()
        {
            var sut         = BoardGridHelper.CreateFourByFourBoard();
            var columnIndex = 3;

            var exception = Assert.Throws <ColumnIsFullException>(
                () => sut.DropValueIntoColumn(BoardSlotValue.P1, columnIndex)
                );

            Assert.Equal(columnIndex, exception.ColumnIndex);
        }
예제 #6
0
 public static IEnumerable <object[]> Can_detect_winner_TestData()
 => BoardGridHelper
 .CreateWinningBoardGridForPlayerOne()
 .Boards
 .Where(x =>
        x.WinMethod != WinMethod.None &&
        x.WinMethod != WinMethod.Draw
        )
 .Select(x => new object[]
 {
     $"Board is in method '{x.WinMethod}' of 4 times",
     x.Board,
     new WinState(x.WinMethod, BoardSlotValue.P1),
 });
예제 #7
0
        public void Can_add_value_to_column(int columnIndex, int expectedSlotsFree)
        {
            var sut = BoardGridHelper.CreateFourByFourBoard();

            var state = sut
                        .DropValueIntoColumn(BoardSlotValue.P1, columnIndex)
                        .State;
            var actualSlotsFree = state
                                  .Count(slot =>
                                         slot.Position.Column == columnIndex &&
                                         slot.Value == BoardSlotValue.Empty
                                         );

            Assert.Equal(expectedSlotsFree, actualSlotsFree);
        }