Exemplo n.º 1
0
        public void GetGameBoardState_ReturnsNewState()
        {
            //Arrange
            object dummy;

            _memCache.Setup(x => x.TryGetValue(It.IsAny <object>(), out dummy)).Returns(false);

            IDictionary <Suits, InGameSuit> expected = new Dictionary <Suits, InGameSuit>
            {
                { Suits.Diamonds, new InGameSuit(Suits.Diamonds) },
                { Suits.Spades, new InGameSuit(Suits.Spades) },
                { Suits.Hearts, new InGameSuit(Suits.Hearts) },
                { Suits.Clubs, new InGameSuit(Suits.Clubs) }
            };

            //Act
            var result = _board.GetGameBoardState();

            //Assert
            result.Should().BeEquivalentTo(expected);
            result.Count.Should().Be(expected.Count);

            result[Suits.Diamonds].LowValue.Should().Be(expected[Suits.Diamonds].LowValue);
            result[Suits.Diamonds].HighValue.Should().Be(expected[Suits.Diamonds].HighValue);

            result[Suits.Spades].LowValue.Should().Be(expected[Suits.Spades].LowValue);
            result[Suits.Spades].HighValue.Should().Be(expected[Suits.Spades].HighValue);

            result[Suits.Hearts].LowValue.Should().Be(expected[Suits.Hearts].LowValue);
            result[Suits.Hearts].HighValue.Should().Be(expected[Suits.Hearts].HighValue);

            result[Suits.Clubs].LowValue.Should().Be(expected[Suits.Clubs].LowValue);
            result[Suits.Clubs].HighValue.Should().Be(expected[Suits.Clubs].HighValue);
        }
Exemplo n.º 2
0
        public async Task <Game> StartGame()
        {
            var boardState = _board.GetGameBoardState();

            CurrentPlayer.FirstTurn(_state);

            var response = new Game
            {
                BoardState = boardState,
                History    = await _state.GetHistory(),
                GameOver   = await _state.IsGameOver(),
                PlayerHand = _humanPlayer.ShowHand(),
                NextPlayer = await GetNextPlayerAsync()
            };

            CurrentPlayer = response.NextPlayer;

            return(response);
        }