public void Act_ShouldSelectOtherPlayer()
        {
            //Arrange
            FakeCell fakeCell = new FakeCell.Builder().Build();
            FakeEnumerator <ICell> fakeEnumerator = new FakeEnumerator <ICell> .Builder()
                                                    .MoveNext(true)
                                                    .Current(fakeCell)
                                                    .Build();

            FakeCellCollection fakeCellCollection = new FakeCellCollection.Builder()
                                                    .GetEnumerator(fakeEnumerator)
                                                    .Build();
            FakeBoard fakeBoardClone = new FakeBoard.Builder()
                                       .ClaimEndsGame(Bool.True)
                                       .Build();
            FakeBoard fakeBoard = new FakeBoard.Builder()
                                  .AvailableSpaces(fakeCellCollection)
                                  .Clone(fakeBoardClone)
                                  .Build();
            FakePlayer           fakePlayer            = new FakePlayer.Builder().Build();
            FakeSelectMoveAction fakeSelectMoveAction  = new FakeSelectMoveAction.Builder().Act(null).Build();
            OtherPlayerWinningSelectMoveAction subject = new OtherPlayerWinningSelectMoveAction(fakeSelectMoveAction);

            //Act
            subject.Act(fakeBoard, null, fakePlayer);

            //Assert
            fakeBoardClone.AssertClaimEndsGameInvokedWith(fakeCell, fakePlayer);
        }
        public void Act_ShouldAttemptToClaimEachCellForWin()
        {
            //Arrange
            FakeCell fakeCell = new FakeCell.Builder().Build();
            FakeEnumerator <ICell> fakeEnumerator = new FakeEnumerator <ICell> .Builder()
                                                    .MoveNext(true, true, true, true, true, false)
                                                    .Current(fakeCell)
                                                    .Build();

            FakeCellCollection fakeCellCollection = new FakeCellCollection.Builder()
                                                    .GetEnumerator(fakeEnumerator)
                                                    .Build();
            FakeBoard fakeBoardClone = new FakeBoard.Builder()
                                       .ClaimEndsGame(Bool.False)
                                       .Build();
            FakeBoard fakeBoard = new FakeBoard.Builder()
                                  .AvailableSpaces(fakeCellCollection)
                                  .Clone(fakeBoardClone)
                                  .Build();
            FakeSelectMoveAction          fakeSelectMoveAction = new FakeSelectMoveAction.Builder().Act(null).Build();
            PlayerWinningSelectMoveAction subject = new AbstractWrapper(fakeSelectMoveAction);

            //Act
            subject.Act(fakeBoard, null, null);

            //Assert
            fakeSelectMoveAction.AssertActInvoked();
            fakeBoard.CloneInvokedCount(5);
            fakeBoardClone.AssertClaimEndsGameInvokedCount(5);
        }
Ejemplo n.º 3
0
        public void IsWin_ShouldReturnTrueWhenIsWin()
        {
            //Arrange
            FakeCell           fakeCell           = new FakeCell.Builder().Value("1").Build();
            FakeCellCollection fakeCellCollection = new FakeCellCollection.Builder().At(fakeCell).Build();
            Win subject = new TestWin(fakeCellCollection, 1, 2, 3);

            //Act
            Bool actual = subject.IsWin();

            //Assert
            ((bool)actual).Should().BeTrue();
        }
Ejemplo n.º 4
0
        public void IsWin_ShouldReturnFalseWhenNotMatch()
        {
            //Arrange
            FakeCell           fakeCell1          = new FakeCell.Builder().Value("1").Build();
            FakeCell           fakeCell2          = new FakeCell.Builder().Value("2").Build();
            FakeCellCollection fakeCellCollection = new FakeCellCollection.Builder().At(fakeCell1, fakeCell2).Build();
            Win subject = new TestWin(fakeCellCollection, 1, 2, 3);

            //Act
            Bool actual = subject.IsWin();

            //Assert
            ((bool)actual).Should().BeFalse();
        }
Ejemplo n.º 5
0
        public void Clone_ShouldReturnBoard()
        {
            //Arrange
            FakeCellCollection fakeCellCollectionClone = new FakeCellCollection.Builder().Build();
            FakeCellCollection fakeCellCollection      = new FakeCellCollection.Builder()
                                                         .Clone(fakeCellCollectionClone)
                                                         .Build();
            Board subject = new Board(fakeCellCollection, null, null);

            //Act
            IBoard actual = subject.Clone();

            //Assert
            actual.Should().BeOfType <Board>();
        }
        public void ShouldInvokeIndexes()
        {
            //Arrange
            FakeCell           fakeCell           = new FakeCell.Builder().Value("").Build();
            FakeCellCollection fakeCellCollection = new FakeCellCollection.Builder().At(fakeCell).Build();
            Int indexOne = new IntOf(1);
            Int indexTwo = new IntOf(2);
            IndexedCellEquality subject = new IndexedCellEquality(fakeCellCollection, indexOne, indexTwo);

            //Act
            bool actual = subject;

            //Assert
            fakeCellCollection.AssertAtInvokedWith(indexOne, indexTwo);
        }
Ejemplo n.º 7
0
        public void ShouldReturnFalseWhenNotAllSelected()
        {
            //Arrange
            FakeCell     fakeCell = new FakeCell.Builder().IsSelected(Bool.False).Build();
            List <ICell> cells    = new List <ICell>()
            {
                fakeCell
            };
            FakeCellCollection fakeCellCollection = new FakeCellCollection.Builder().GetEnumerator(cells.GetEnumerator()).Build();
            AllCellsSelected   subject            = new AllCellsSelected(fakeCellCollection);

            //Act
            bool actual = subject;

            //Assert
            actual.Should().BeFalse();
        }
Ejemplo n.º 8
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();
        }
        public void Act_ShouldInvokeActWhenNoSpacesAvailable()
        {
            //Arrange
            FakeEnumerator <ICell> fakeEnumerator = new FakeEnumerator <ICell> .Builder()
                                                    .MoveNext(false)
                                                    .Build();

            FakeCellCollection fakeCellCollection = new FakeCellCollection.Builder()
                                                    .GetEnumerator(fakeEnumerator)
                                                    .Build();
            FakeBoard                     fakeBoard            = new FakeBoard.Builder().AvailableSpaces(fakeCellCollection).Build();
            FakeSelectMoveAction          fakeSelectMoveAction = new FakeSelectMoveAction.Builder().Act(null).Build();
            PlayerWinningSelectMoveAction subject = new AbstractWrapper(fakeSelectMoveAction);

            //Act
            subject.Act(fakeBoard, null, null);

            //Assert
            fakeSelectMoveAction.AssertActInvoked();
        }
Ejemplo n.º 10
0
        public void Act_ShouldSelectRandomSpace()
        {
            //Arrange
            Int                expectedMax        = new IntOf(57);
            FakeCell           fakeCell           = new FakeCell.Builder().Build();
            FakeCellCollection fakeCellCollection = new FakeCellCollection.Builder()
                                                    .Count(expectedMax)
                                                    .At(fakeCell)
                                                    .Build();
            FakeBoard fakeBoard = new FakeBoard.Builder()
                                  .AvailableSpaces(fakeCellCollection)
                                  .Build();
            RandomSpaceSelectMoveAction subject = new RandomSpaceSelectMoveAction();

            //Act
            ICell actual = subject.Act(fakeBoard, null, null);

            //Assert
            actual.Should().BeOfType <RandomCell>();
        }