public async Task PlayerHeroStats_PlayerAgainstTwoEnemies_PlayerShouldHaveCorrectHeroStats() { var playerRepository = new PlayerStatsRepository(MongoClient); var playerHeroStatsHandler = new PlayerHeroStatsHandler(playerRepository); var player = CreatePlayer("player#123", Race.HU, won: true); var playerHeroes = CreateHeroes("archmage", "mountainking"); var enemyUdPlayer = CreatePlayer("enemyUd#567", Race.UD); var enemyUdHeroes = CreateHeroes("deathknight", "lich"); // Match 1 Hu vs UD MatchFinishedEvent match1 = CreateMatchEvent(player, playerHeroes, enemyUdPlayer, enemyUdHeroes); await playerHeroStatsHandler.Update(match1); // Match 2 Hu vs NE var enemyNePlayer = CreatePlayer("enemyNe#89", Race.NE); var enemyNeHeroes = CreateHeroes("deamonhunter"); MatchFinishedEvent match2 = CreateMatchEvent(player, playerHeroes, enemyNePlayer, enemyNeHeroes); await playerHeroStatsHandler.Update(match2); var playerHeroStats = await playerRepository.LoadHeroStat(player.battleTag, 0); var enemyUdHeroStats = await playerRepository.LoadHeroStat(enemyUdPlayer.battleTag, 0); var enemyNeHeroStats = await playerRepository.LoadHeroStat(enemyNePlayer.battleTag, 0); // *** Player hero stats Assert.AreEqual(player.battleTag, playerHeroStats.BattleTag); Assert.AreEqual(2, playerHeroStats.HeroStatsItemList.Count); // Archmage Stats var playerAmStats = GetHeroStatsForRaceAndMap(playerHeroStats, "archmage", Race.HU, "Overall"); var playerAmVsUd = playerAmStats.WinLosses.Single(x => x.Race == Race.UD); Assert.AreEqual(1, playerAmVsUd.Wins); Assert.AreEqual(0, playerAmVsUd.Losses); var playerAmVsNe = playerAmStats.WinLosses.Single(x => x.Race == Race.UD); Assert.AreEqual(1, playerAmVsNe.Wins); Assert.AreEqual(0, playerAmVsNe.Losses); // Mountain king Stats var playerMKStats = GetHeroStatsForRaceAndMap(playerHeroStats, "mountainking", Race.HU, "Overall"); var playerMKVsUd = playerMKStats.WinLosses.Single(x => x.Race == Race.UD); Assert.AreEqual(1, playerMKVsUd.Wins); Assert.AreEqual(0, playerMKVsUd.Losses); var playerMKVsNe = playerMKStats.WinLosses.Single(x => x.Race == Race.UD); Assert.AreEqual(1, playerMKVsNe.Wins); Assert.AreEqual(0, playerMKVsNe.Losses); }
public async Task PlayerHeroStats_PlayerAgainstEnemyAndPlayerLosses_EnemyShouldHaveCorrectHeroStats(Race enemyRace) { var playerRepository = new PlayerStatsRepository(MongoClient); var playerHeroStatsHandler = new PlayerHeroStatsHandler(playerRepository); var player = CreatePlayer("player#123", Race.HU, won: false); var playerHeroes = CreateHeroes("playerhero"); var enemyPlayer = CreatePlayer("enemy#567", enemyRace, won: true); var enemyUdHeroes = CreateHeroes("enemyhero"); MatchFinishedEvent match1 = CreateMatchEvent(player, playerHeroes, enemyPlayer, enemyUdHeroes); await playerHeroStatsHandler.Update(match1); var enemyHerosStats = await playerRepository.LoadHeroStat(enemyPlayer.battleTag, 0); Assert.AreEqual(enemyPlayer.battleTag, enemyHerosStats.BattleTag); Assert.AreEqual(1, enemyHerosStats.HeroStatsItemList.Count); var enemyHeroStats = GetHeroStatsForRaceAndMap(enemyHerosStats, "enemyhero", enemyRace, "Overall"); var enemyStatsVsPlayerRace = enemyHeroStats.WinLosses.Single(x => x.Race == Race.HU); Assert.AreEqual(1, enemyStatsVsPlayerRace.Wins); Assert.AreEqual(0, enemyStatsVsPlayerRace.Losses); }