public async Task GetPopularServers_ReturnsCorrectStatistics() { var date = DateTime.Now.Date; var server = new ServerInfoEntry { Endpoint = "GetPopularServers_ReturnsCorrectStatistics1", Name = "Server1", GameModes = new List <StringEntry> { new StringEntry { String = "DM" }, new StringEntry { String = "TDM" } } }; var expected = new List <PopularServerEntry> { new PopularServerEntry { Endpoint = "GetBestPlayers_ReturnsCorrectStatistics", Name = "Test", AverageMatchesPerDay = 20 }, new PopularServerEntry { Endpoint = "GetPopularServers_ReturnsCorrectStatistics1", Name = "Server1", AverageMatchesPerDay = 15 } }; await statistics.PutServerInfo(server.Endpoint, new ServerInfoEntry { Name = server.Name, GameModes = server.GameModes }); for (var i = 0; i < 15; i++) { await statistics.PutMatchInfo(server.Endpoint, date + TimeSpan.FromHours(i), new MatchInfoEntry { Map = "1", GameMode = "2", FragLimit = 20, TimeLimit = 300, TimeElapsed = 25, Scoreboard = new List <ScoreEntry> { new ScoreEntry { Name = "GetPopularServers_ReturnsCorrectStatistics1", Deaths = 1, Frags = 2, Kills = 20 }, new ScoreEntry { Name = "GetPopularServers_ReturnsCorrectStatistics2", Deaths = 1, Frags = 20, Kills = 2 } } }); } var result = statistics.GetPopularServers(2).Result.ToList(); result.Count.ShouldBeEquivalentTo(expected.Count); for (var i = 0; i < expected.Count; i++) { result[i].ShouldBeEquivalentTo(expected[i]); } }
public async Task <List <PopularServer> > GetPopularServersInfo(int count = 5) { return(await statistics.GetPopularServers(Clamp(count))); }