Ejemplo n.º 1
0
        public void GameIsFinishedWhenTheCurrentAdvokatIsBlockedAndHeStartHisMoveWithAnAdvokatToken()
        {
            this.board.SelectByPosition(4, 4).Token = new AdvocatToken { Color = Colors.Red };
            this.board.SelectByPosition(3, 4).Token = new ParagraphToken();
            this.board.SelectByPosition(5, 4).Token = new ParagraphToken();
            this.board.SelectByPosition(4, 3).Token = new ParagraphToken();
            this.board.SelectByPosition(4, 5).Token = new ParagraphToken();

            A.CallTo(() => this.fieldListFactory.Create(A<int>._, A<int>._)).Returns(this.board);

            this.testee = new GameBoard(this.fieldListFactory, 1);

            var result = this.testee.PlaceToken(this.board.SelectByPosition(4, 4));
            result.IsValid.Should().Be(false);
            result.Message.StartsWith("Spiel beendet!").Should().Be(true);
        }
Ejemplo n.º 2
0
        public void GetCurrentScoreReturnsAnEmptyList_WhenTheFieldsAreEmpty()
        {
            var board = this.Create8x8Board();

            A.CallTo(() => this.fieldListFactory.Create(A<int>._, A<int>._)).Returns(board);

            this.testee = new GameBoard(this.fieldListFactory, 1);

            var currentScore = this.testee.GetCurrentScore();

            currentScore.Should().BeEmpty();
        }
Ejemplo n.º 3
0
        public void GetCurrentScoreReturnsAListOfZeroScores_WhenOnlyAdvocatTokensArePresent()
        {
            var board = this.Create8x8Board();

            board.SelectByPosition(0, 0).Token = new AdvocatToken();
            board.SelectByPosition(0, 7).Token = new AdvocatToken();
            board.SelectByPosition(7, 0).Token = new AdvocatToken();
            board.SelectByPosition(7, 7).Token = new AdvocatToken();

            A.CallTo(() => this.fieldListFactory.Create(A<int>._, A<int>._)).Returns(board);

            this.testee = new GameBoard(this.fieldListFactory, 4);

            var currentScore = this.testee.GetCurrentScore().ToList();

            currentScore.Should().OnlyContain(s => s.Score == 0);
            currentScore.Count().Should().Be(4);
        }
Ejemplo n.º 4
0
        public void FieldListPropertyIsLoadedFromFieldListFactory()
        {
            this.testee = new GameBoard(this.fieldListFactory, 4);

            this.testee.Fields.Count().Should().Be(64);
        }
Ejemplo n.º 5
0
        public void WinkelzugIsPossibleWhenNoOtherTokensArePresent()
        {
            this.board.SelectByPosition(4, 4).Token = new AdvocatToken();

            this.testee = new GameBoard(this.fieldListFactory, 1);

            this.testee.IsWinkelzugPossible(this.board.SelectByPosition(4, 4)).Should().Be(true);
        }
Ejemplo n.º 6
0
        public void WinkelzugPossibleWhenOnlyOneWinkelzugPossible2()
        {
            this.board.SelectByPosition(4, 4).Token = new AdvocatToken();

            this.board.SelectByPosition(5, 4).Token = new ParagraphToken();
            this.board.SelectByPosition(4, 3).Token = new ParagraphToken();
            this.board.SelectByPosition(4, 5).Token = new ParagraphToken();

            this.board.SelectByPosition(3, 3).Token = new ParagraphToken();
            this.board.SelectByPosition(2, 3).Token = new ParagraphToken();
            this.board.SelectByPosition(1, 3).Token = new ParagraphToken();
            this.board.SelectByPosition(3, 5).Token = new ParagraphToken();
            this.board.SelectByPosition(2, 5).Token = new ParagraphToken();
            this.board.SelectByPosition(1, 6).Token = new ParagraphToken();
            this.board.SelectByPosition(0, 5).Token = new ParagraphToken();
            this.board.SelectByPosition(0, 4).Token = new ParagraphToken();

            this.testee = new GameBoard(this.fieldListFactory, 1);

            this.testee.IsWinkelzugPossible(this.board.SelectByPosition(4, 4)).Should().Be(true);
        }
Ejemplo n.º 7
0
        public void WinkelZugIsPossibleWhenNoOtherTokenAndAdvokatIsInCorner()
        {
            this.board.SelectByPosition(0, 0).Token = new AdvocatToken();

            this.testee = new GameBoard(this.fieldListFactory, 1);

            this.testee.IsWinkelzugPossible(this.board.SelectByPosition(4, 4)).Should().Be(true);
        }
Ejemplo n.º 8
0
        public void Setup()
        {
            this.fieldListFactory = A.Fake<IFieldListFactory>();
            this.board = this.Create8x8Board();
            A.CallTo(() => this.fieldListFactory.Create(A<int>._, A<int>._)).Returns(this.board);
            this.moveFactory = A.Fake<IMoveFactory>();

            this.testee = new GameBoard(this.fieldListFactory, this.moveFactory, 4);
        }
Ejemplo n.º 9
0
        public void NoWinkelzugPossibleWhenSurroundedByTokens()
        {
            this.board.SelectByPosition(4, 4).Token = new AdvocatToken();

            this.board.SelectByPosition(3, 4).Token = new ParagraphToken();
            this.board.SelectByPosition(5, 4).Token = new ParagraphToken();
            this.board.SelectByPosition(4, 3).Token = new ParagraphToken();
            this.board.SelectByPosition(4, 5).Token = new ParagraphToken();

            this.testee = new GameBoard(this.fieldListFactory, 1);

            this.testee.IsWinkelzugPossible(this.board.SelectByPosition(4, 4)).Should().Be(false);
        }
Ejemplo n.º 10
0
        public void GetCurrentScoreReturnsValueOfField_WhenOneParagraphTokenIsPresent()
        {
            var board = this.Create8x8Board();

            board.SelectByPosition(0, 0).Token = new AdvocatToken() { Color = Colors.Black };

            this.AddParagraphTokenToField(board, Colors.Black, 2, 0, 1);

            A.CallTo(() => this.fieldListFactory.Create(A<int>._, A<int>._)).Returns(board);

            this.testee = new GameBoard(this.fieldListFactory, 1);

            var currentScore = this.testee.GetCurrentScore().ToList();

            currentScore.Should().OnlyContain(s => s.Score == 2);
            currentScore.Count().Should().Be(1);
        }
Ejemplo n.º 11
0
        public void GetCurrentScoreReturnsSumOfFieldValuesPerColor_WhenSomeParagraphTokensArePresent()
        {
            var board = this.Create8x8Board();

            board.SelectByPosition(0, 0).Token = new AdvocatToken() { Color = Colors.Black };
            board.SelectByPosition(7, 0).Token = new AdvocatToken() { Color = Colors.White };
            board.SelectByPosition(0, 7).Token = new AdvocatToken() { Color = Colors.Blue };

            this.AddParagraphTokenToField(board, Colors.Black, 2, 0, 1);
            this.AddParagraphTokenToField(board, Colors.Black, 4, 1, 1);
            this.AddParagraphTokenToField(board, Colors.White, 2, 0, 6);
            this.AddParagraphTokenToField(board, Colors.White, 8, 4, 2);
            this.AddParagraphTokenToField(board, Colors.Blue, 2, 7, 2);
            this.AddParagraphTokenToField(board, Colors.Blue, 16, 4, 3);
            this.AddParagraphTokenToField(board, Colors.Blue, 8, 5, 2);

            A.CallTo(() => this.fieldListFactory.Create(A<int>._, A<int>._)).Returns(board);

            this.testee = new GameBoard(this.fieldListFactory, 1);

            var currentScore = this.testee.GetCurrentScore().ToList();

            currentScore.Should().Contain(s => s.Color == Colors.Black && s.Score == 6);
            currentScore.Should().Contain(s => s.Color == Colors.White && s.Score == 10);
            currentScore.Should().Contain(s => s.Color == Colors.Blue && s.Score == 26);
        }