public async Task ReturnRanks_WhenPlayersHavePersonalSettingsConfigured_MustHaveCorrectPersonalSettings() { // Arrange var rankRepository = new RankRepository(MongoClient, personalSettingsProvider); var playerRepository = new PlayerRepository(MongoClient); var personalSettingsRepository = new PersonalSettingsRepository(MongoClient); var clanRepository = new ClanRepository(MongoClient); var queryHandler = new RankQueryHandler(rankRepository, playerRepository, clanRepository); var ranks = new List <Rank> { new Rank(new List <string> { "peter#123" }, 1, 12, 1456, null, GateWay.America, GameMode.GM_1v1, 1) }; await rankRepository.InsertRanks(ranks); var player = PlayerOverview.Create(new List <PlayerId> { PlayerId.Create("peter#123") }, GateWay.America, GameMode.GM_1v1, 1, null); player.RecordWin(true, 1234); await playerRepository.UpsertPlayerOverview(player); var playerStats = new PlayerOverallStats() { BattleTag = "peter#123", }; await playerRepository.UpsertPlayer(playerStats); var settings = new PersonalSetting("peter#123") { ProfilePicture = new ProfilePicture() { Race = AvatarCategory.HU, PictureId = 5 }, Country = "BG" }; await personalSettingsRepository.Save(settings); // Act var playerLoaded = await queryHandler.LoadPlayersOfLeague(1, 1, GateWay.America, GameMode.GM_1v1); // Assert Assert.AreEqual(1, playerLoaded.Count); var playerRank = playerLoaded[0]; Assert.AreEqual("1_peter#123@10_GM_1v1", playerRank.Players.First().Id); Assert.AreEqual(playerRank.PlayersInfo[0].SelectedRace, AvatarCategory.HU); Assert.AreEqual(playerRank.PlayersInfo[0].PictureId, 5); Assert.AreEqual(playerRank.PlayersInfo[0].Country, "BG"); }
public async Task ReturnRanks_WithRaceSpecificRank() { // Arrange var rankRepository = new RankRepository(MongoClient); var playerRepository = new PlayerRepository(MongoClient); var queryHandler = new RankQueryHandler(rankRepository, playerRepository, new ClanRepository(MongoClient)); var ranks = new List <Rank> { new Rank(new List <string> { "peter#123" }, 1, 2, 1000, Race.HU, GateWay.America, GameMode.GM_1v1, 2), new Rank(new List <string> { "peter#123" }, 1, 3, 2000, Race.NE, GateWay.America, GameMode.GM_1v1, 2) }; await rankRepository.InsertRanks(ranks); var player1 = PlayerOverview.Create(new List <PlayerId> { PlayerId.Create("peter#123") }, GateWay.America, GameMode.GM_1v1, 2, Race.HU); player1.RecordWin(true, 1234); await playerRepository.UpsertPlayerOverview(player1); var player2 = PlayerOverview.Create(new List <PlayerId> { PlayerId.Create("peter#123") }, GateWay.America, GameMode.GM_1v1, 2, Race.NE); player2.RecordWin(true, 1234); await playerRepository.UpsertPlayerOverview(player2); // Act var playerLoaded = await queryHandler.LoadPlayersOfLeague(1, 2, GateWay.America, GameMode.GM_1v1); // Assert Assert.AreEqual(2, playerLoaded.Count); Assert.AreEqual("peter#123", playerLoaded[0].Player.PlayerIds.Single().BattleTag); Assert.AreEqual("peter#123", playerLoaded[1].Player.PlayerIds.Single().BattleTag); }
public async Task ReturnRanks_ClanGetsResolved() { // Arrange var rankRepository = new RankRepository(MongoClient); var playerRepository = new PlayerRepository(MongoClient); var clanRepository = new ClanRepository(MongoClient); var queryHandler = new RankQueryHandler(rankRepository, playerRepository, clanRepository); var ranks = new List <Rank> { new Rank(new List <string> { "peter#123" }, 1, 12, 1456, GateWay.America, GameMode.GM_1v1, 1) }; await rankRepository.InsertRanks(ranks); var player = PlayerOverview.Create(new List <PlayerId> { PlayerId.Create("peter#123") }, GateWay.America, GameMode.GM_1v1, 1); player.RecordWin(true, 1234); await playerRepository.UpsertPlayerOverview(player); var playerStats = new PlayerOverallStats() { BattleTag = "peter#123", }; await playerRepository.UpsertPlayer(playerStats); await clanRepository.UpsertMemberShip(new ClanMembership { BattleTag = "peter#123", ClanId = "W3C" }); // Act var playerLoaded = await queryHandler.LoadPlayersOfLeague(1, 1, GateWay.America, GameMode.GM_1v1); // Assert Assert.AreEqual(1, playerLoaded.Count); var playerRank = playerLoaded[0]; Assert.AreEqual("W3C", playerRank.PlayersInfo.Single().ClanId); }
public async Task ReturnRanks_WhenPlayersDoNotHavePersonalSettingsConfigured_MustHaveNotThrowError() { // Arrange var rankRepository = new RankRepository(MongoClient); var playerRepository = new PlayerRepository(MongoClient); var clanRepository = new ClanRepository(MongoClient); var queryHandler = new RankQueryHandler(rankRepository, playerRepository, clanRepository); var ranks = new List <Rank> { new Rank(new List <string> { "peter#123" }, 1, 12, 1456, GateWay.America, GameMode.GM_1v1, 1) }; await rankRepository.InsertRanks(ranks); var player = PlayerOverview.Create(new List <PlayerId> { PlayerId.Create("peter#123") }, GateWay.America, GameMode.GM_1v1, 1); player.RecordWin(true, 1234); await playerRepository.UpsertPlayerOverview(player); var playerStats = new PlayerOverallStats() { BattleTag = "peter#123", }; await playerRepository.UpsertPlayer(playerStats); // Act var playerLoaded = await queryHandler.LoadPlayersOfLeague(1, 1, GateWay.America, GameMode.GM_1v1); // Assert Assert.AreEqual(1, playerLoaded.Count); var playerRank = playerLoaded[0]; Assert.AreEqual("1_peter#123@10_GM_1v1", playerRank.Players.First().Id); }