public async Task GetBestPlayers_DoesNotCountPlayersWithLessThen10Games() { var expected = new BestPlayer[0]; var result = await statistics.GetBestPlayers(50); result.ShouldBeEquivalentTo(expected); }
private async Task InsertBestPlayersAsync(List <Scoreboard> scoreboards, SQLiteConnection connection, SQLiteTransaction transaction) { var bestPlayers = new List <BestPlayer>(); foreach (var scoreboard in scoreboards) { var playerList = await ExecuteReaderAsync(Queries.SelectPlayer(scoreboard.Name.ToLower()), connection, transaction, DataReaderHelper.GetPlayer); var player = playerList.FirstOrDefault(); var newPlayer = new BestPlayer(scoreboard.Name, (player?.Frags ?? 0) + scoreboard.Frags, (player?.Kills ?? 0) + scoreboard.Kills, (player?.Deaths ?? 0) + scoreboard.Deaths, (player?.MatchCount ?? 0) + 1 ); bestPlayers.Add(newPlayer); } var command = new SQLiteCommand(Queries.InsertPlayers(bestPlayers), connection, transaction); await command.ExecuteNonQueryAsync(); }