Ejemplo n.º 1
0
        public void CanDetectIfTheGameHasEnded()
        {
            var seeBoard = new SeeBoard(new AntidiagonalWinStub(0));

            var response = seeBoard.Execute();

            Assert.That(response.HasGameEnded, Is.True);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
        public void CanDetectIfTheGameHasNotEnded()
        {
            var boardGateway = new BoardReaderStub();

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

            Assert.That(response.HasGameEnded, Is.False);
        }
Ejemplo n.º 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
                );
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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
                );
        }
Ejemplo n.º 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
                );
        }
Ejemplo n.º 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
                );
        }
Ejemplo n.º 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);
        }