public async Task Should_add_player_to_game()
        {
            var game = new GameBuilder()
                       .FirstPlayerEinstein
                       .CardBattle
                       .Build();
            await _repository.CreateGameAsync(game);

            // Act
            var updatedGame = await _repository.AddPlayerToGameAsync(GameType.CardBattle, null, null, GameBuilder.Eiffel);

            updatedGame.Should().NotBeNull();
            updatedGame !.PlayersCount.Should().Be(2);
            updatedGame.Players.Should().BeEquivalentTo(new[]
            {
                GameBuilder.Einstein,
                GameBuilder.Eiffel
            }, options => options.WithMongoDateTime());
            updatedGame.Version.Should().Be(game.Version + 1);
        }
        public async Task Should_add_player_when_not_there()
        {
            var game = new GameBuilder()
                       .TicTacToe
                       .FirstPlayerEinstein
                       .Build();

            game = await _repository.CreateGameAsync(game);

            // Act
            var updatedGame = await _repository.AddPlayerToGameIfNotThereAsync(game.Id !, GameBuilder.Eiffel);

            updatedGame.Should().NotBeNull();
            updatedGame !.PlayersCount.Should().Be(2);
            updatedGame.Players.Should().BeEquivalentTo(new[]
            {
                GameBuilder.Einstein,
                GameBuilder.Eiffel
            }, options => options.WithMongoDateTime());
        }
Esempio n. 3
0
 public Game()
 {
     Genre   = string.Empty;
     Players = PlayersCount.NotDefined;
 }