Пример #1
0
        public void CanDetectIfTheGameHasEnded()
        {
            var seeBoard = new SeeBoard(new AntidiagonalWinStub(0));

            var response = seeBoard.Execute();

            Assert.That(response.HasGameEnded, Is.True);
        }
Пример #2
0
        public void CanDetectADiagonalWin(int pieceType)
        {
            var seeBoard = new SeeBoard(new DiagonalWinStub(pieceType));

            var response = seeBoard.Execute();

            Assert.That(response.Winner, Is.EqualTo(pieceType));
        }
Пример #3
0
        public void GivenANewGame_WhenISeeTheBoard_ItMustBeEmpty()
        {
            var seeBoard = new SeeBoard(boardGateway);
            var response = seeBoard.Execute();

            Assert.AreEqual(new int?[3, 3], response.Board);
            Assert.That(response.Winner, Is.Null);
        }
Пример #4
0
        public void CanDetectAVerticalWin2(int x)
        {
            var verticalWinStub = new VerticalWinStub(x, 1);
            var seeBoard        = new SeeBoard(verticalWinStub);

            var response = seeBoard.Execute();

            Assert.That(response.Winner, Is.EqualTo(1));
        }
Пример #5
0
        public void TestInitialBoardState()
        {
            var boardGateway = new BoardReaderStub();

            var seeBoard = new SeeBoard(boardGateway);
            var response = seeBoard.Execute();

            Assert.AreEqual(new int?[3, 3], response.Board);
        }
Пример #6
0
        public void CanDetectAHorizontalWin2(int y)
        {
            var horizontalWinStub = new HorizontalWinStub(y, 1);
            var seeBoard          = new SeeBoard(horizontalWinStub);

            var response = seeBoard.Execute();

            Assert.That(response.Winner, Is.EqualTo(1));
        }
Пример #7
0
        public void CanDetectIfTheGameHasEndedWithATie()
        {
            var seeBoard = new SeeBoard(new TieStub());

            var response = seeBoard.Execute();

            Assert.That(response.HasGameEnded, Is.True);
            Assert.That(response.Winner, Is.Null);
        }
Пример #8
0
        public void CanDetectIfTheGameHasNotEnded()
        {
            var boardGateway = new BoardReaderStub();

            var seeBoard = new SeeBoard(boardGateway);
            var response = seeBoard.Execute();

            Assert.That(response.HasGameEnded, Is.False);
        }
Пример #9
0
        public void TestFoo()
        {
            var boardGateway = new PieceInTheMiddleBoardReaderStub();

            var seeBoard = new SeeBoard(boardGateway);
            var response = seeBoard.Execute();

            Assert.AreEqual(
                new int?[, ]
            {
                { null, null, null },
                { null, 1, null },
                { null, null, null }
            },
                response.Board
                );
        }
Пример #10
0
        public void CanDetectAWinForOAntiDiagonally()
        {
            var placePiece = new PlacePiece(boardGateway, boardGateway);

            placePiece.Execute(2, 0);
            placePiece.Execute(1, 0);

            placePiece.Execute(1, 1);
            placePiece.Execute(2, 1);

            placePiece.Execute(0, 2);

            var seeBoard = new SeeBoard(boardGateway);
            var response = seeBoard.Execute();

            Assert.That(response.Winner, Is.EqualTo(0));
        }
Пример #11
0
        public void CanDetectAWinForOHorizontally()
        {
            var placePiece = new PlacePiece(boardGateway, boardGateway);

            placePiece.Execute(0, 0);
            placePiece.Execute(0, 1);

            placePiece.Execute(1, 0);
            placePiece.Execute(1, 1);

            placePiece.Execute(2, 0);

            var seeBoard = new SeeBoard(boardGateway);
            var response = seeBoard.Execute();

            Assert.That(response.Winner, Is.Zero);
        }
Пример #12
0
        public void GivenAGameWithOnePiecePlaced_WhenISeeTheBoard_ThenTheBoardIsUpdatedCorrectly()
        {
            var placePiece = new PlacePiece(boardGateway, boardGateway);

            placePiece.Execute(0, 0);

            var seeBoard = new SeeBoard(boardGateway);
            var response = seeBoard.Execute();

            Assert.AreEqual(
                new int?[, ]
            {
                { 0, null, null },
                { null, null, null },
                { null, null, null }
            },
                response.Board
                );
        }
Пример #13
0
        public void WhenANewPieceIsPlaced_MustBeDifferentFrom_ThePrevious()
        {
            var placePiece = new PlacePiece(boardGateway, boardGateway);

            placePiece.Execute(0, 0);
            placePiece.Execute(0, 1);

            var seeBoard = new SeeBoard(boardGateway);
            var response = seeBoard.Execute();

            Assert.AreEqual(
                new int?[, ]
            {
                { 0, null, null },
                { 1, null, null },
                { null, null, null }
            },
                response.Board
                );
        }
Пример #14
0
        public void CanNotOverwriteExistingPiece()
        {
            var placePiece = new PlacePiece(boardGateway, boardGateway);

            placePiece.Execute(0, 0);

            placePiece.Execute(0, 0);
            placePiece.Execute(0, 2);

            var seeBoard = new SeeBoard(boardGateway);
            var response = seeBoard.Execute();

            Assert.AreEqual(
                new int?[, ]
            {
                { 0, null, null },
                { null, null, null },
                { 1, null, null }
            },
                response.Board
                );
        }
Пример #15
0
        public void GivenAllThePiecesArePlaced_AndThereIsNoWinner_CanDetectATie()
        {
            var placePiece = new PlacePiece(boardGateway, boardGateway);

            placePiece.Execute(0, 2);
            placePiece.Execute(1, 2);

            placePiece.Execute(2, 2);
            placePiece.Execute(1, 1);

            placePiece.Execute(0, 1);
            placePiece.Execute(0, 0);

            placePiece.Execute(1, 0);
            placePiece.Execute(2, 0);

            placePiece.Execute(2, 1);

            var seeBoard = new SeeBoard(boardGateway);
            var response = seeBoard.Execute();

            Assert.That(response.Winner, Is.Null);
            Assert.That(response.HasGameEnded, Is.True);
        }