Esempio n. 1
0
        protected async Task <GameId> CreateGameAsync(
            NpgsqlConnectionFactory connectionFactory,
            NewPlayer?player1 = null,
            NewPlayer?player2 = null)
        {
            var gameStore = new PostgresGameStore(connectionFactory);

            var newGame = new NewGame(
                players: new PlayerList(
                    randomFirstPlayer: false,
                    player1 ?? new NewPlayer(Player1, PlayerType.User),
                    player2 ?? new NewPlayer(Player2, PlayerType.User)),
                firstPlayerIndex: 0,
                seed: new Seed(42),
                boardType: BoardType.OneEyedJack,
                numSequencesToWin: 2);

            return(await gameStore.PersistNewGameAsync(newGame, CancellationToken.None));
        }
Esempio n. 2
0
        public async Task CanPersistNewGame()
        {
            // Given:
            var db = await CreateDatabaseAsync();

            var sut     = new PostgresGameStore(db);
            var newGame = new NewGame(
                players: new PlayerList(
                    randomFirstPlayer: false,
                    new NewPlayer(Player1, PlayerType.User),
                    new NewPlayer(Player2, PlayerType.User)),
                firstPlayerIndex: 0,
                seed: new Seed(42),
                boardType: BoardType.OneEyedJack,
                numSequencesToWin: 2);

            // When:
            var gameId = await sut.PersistNewGameAsync(newGame, CancellationToken.None);

            // Then:
            Assert.NotNull(gameId);
        }
Esempio n. 3
0
        public async Task CanPersistNewGameWithMultipleIdenticalBots()
        {
            // Given:
            var db = await CreateDatabaseAsync();

            var sut     = new PostgresGameStore(db);
            var botType = new PlayerHandle("Dalvik");
            var newGame = new NewGame(
                players: new PlayerList(
                    randomFirstPlayer: false,
                    new NewPlayer(botType, PlayerType.Bot),
                    new NewPlayer(botType, PlayerType.Bot)),
                firstPlayerIndex: 0,
                seed: new Seed(42),
                boardType: BoardType.Sequence,
                numSequencesToWin: 2);

            // When:
            var gameId = await sut.PersistNewGameAsync(newGame, CancellationToken.None);

            // Then:
            Assert.NotNull(gameId);
        }