Exemplo n.º 1
0
        public void ShouldReturnFalseGivenGameOver()
        {
            //Arrange
            FakePlayerEndsGameAction          fakePlayerEndsGameAction = new FakePlayerEndsGameAction.Builder().Build();
            GameOverGuardPlayerEndsGameAction subject = new GameOverGuardPlayerEndsGameAction(fakePlayerEndsGameAction);
            FakeGameState fakeGameState = new FakeGameState.Builder().IsGameOver(Bool.True).Build();
            FakeBoard     fakeBoard     = new FakeBoard.Builder().GameState(fakeGameState).Build();
            //Act
            bool actual = subject.Act(fakeBoard, null, null);

            //Assert
            actual.Should().BeFalse();
        }
Exemplo n.º 2
0
        public void ShouldReturnTrueGivenNotHasWinner()
        {
            //Arrange
            FakePlayerEndsGameAction       fakePlayerEndsGameAction = new FakePlayerEndsGameAction.Builder().Build();
            NoWinGuardPlayerEndsGameAction subject = new NoWinGuardPlayerEndsGameAction(fakePlayerEndsGameAction);
            FakeGameState fakeGameState            = new FakeGameState.Builder().HasWinner(Bool.False).Build();
            FakeBoard     fakeBoard = new FakeBoard.Builder().GameState(fakeGameState).Build();
            //Act
            bool actual = subject.Act(fakeBoard, null, null);

            //Assert
            actual.Should().BeFalse();
        }
Exemplo n.º 3
0
        public void ShouldReturnTieStatus()
        {
            //Arrange
            Bool          expected      = Bool.True;
            FakeGameState fakeGameState = new FakeGameState.Builder().IsTie(expected).Build();
            FakeBoard     fakeBoard     = new FakeBoard.Builder().GameState(fakeGameState).Build();
            TieEndsGame   subject       = new TieEndsGame(fakeBoard);

            //Act
            bool actual = subject;

            //Assert
            actual.Should().BeTrue();
        }
Exemplo n.º 4
0
        public void AvailableSpaces_ShouldHaveOnlyAvailableCells()
        {
            //Arrange
            FakePrinter   fakePrinter      = new FakePrinter.Builder().Build();
            FakeGameState fakeGameState    = new FakeGameState.Builder().Build();
            FakeCell      fakeCell         = new FakeCell.Builder().IsSelected(Bool.False).Build();
            FakeCell      fakeCellSelected = new FakeCell.Builder().IsSelected(Bool.True).Build();
            Board         subject          = new Board(new CellCollection(new ICell[] { fakeCell, fakeCellSelected }),
                                                       fakeGameState, fakePrinter);

            //Act
            ICellCollection actual = subject.AvailableSpaces();

            //Assert
            ((int)actual.Count()).Should().Be(1);
        }
Exemplo n.º 5
0
        public void ClaimEndsGame_ReturnTrueWhenOver()
        {
            //Arrange
            FakePrinter        fakePrinter        = new FakePrinter.Builder().Build();
            FakeCell           fakeCell           = new FakeCell.Builder().Build();
            FakeCellCollection fakeCellCollection = new FakeCellCollection.Builder()
                                                    .UpdateTo()
                                                    .Build();
            FakeGameState fakeGameState = new FakeGameState.Builder().IsGameOver(Bool.True).Build();
            FakePlayer    fakePlayer    = new FakePlayer.Builder().Cell(fakeCell).Build();
            Board         subject       = new Board(fakeCellCollection, fakeGameState, fakePrinter);

            //Act
            Bool actual = subject.ClaimEndsGame(null, fakePlayer);

            //Assert
            ((bool)actual).Should().BeTrue();
        }
Exemplo n.º 6
0
        public void ClaimEndsGame_ShouldClaimCellForPlayer()
        {
            //Arrange
            FakePrinter     fakePrinter      = new FakePrinter.Builder().Build();
            FakeCell        fakeCellBoard    = new FakeCell.Builder().IsSelected(Bool.False).Value("1").Build();
            FakeCell        fakeCellSelected = new FakeCell.Builder().IsSelected(Bool.False).Value("1").Build();
            FakeCell        fakeCellPlayer   = new FakeCell.Builder().AsSelected(fakeCellSelected).Value("1").Build();
            ICellCollection cellCollection   = new CellCollection(new ICell[] { fakeCellBoard });
            FakeGameState   fakeGameState    = new FakeGameState.Builder().IsGameOver(Bool.False).Build();
            FakePlayer      fakePlayer       = new FakePlayer.Builder().Cell(fakeCellPlayer).Build();
            Board           subject          = new Board(cellCollection, fakeGameState, fakePrinter);

            //Act
            subject.ClaimEndsGame(fakeCellBoard, fakePlayer);

            //Assert
            cellCollection.At(new IntOf(0)).Should().NotBe(fakeCellBoard);
        }