public async Task InsertMatchesFail1() { var fakeEvent = TestDtoHelper.CreateFakeEvent(); fakeEvent.match.map = "Maps/frozenthrone/community/(2)amazonia.w3x"; fakeEvent.match.state = 3; var mockEvents = new Mock <IMatchEventRepository>(); mockEvents.SetupSequence(m => m.Load(It.IsAny <string>(), It.IsAny <int>())) .ReturnsAsync(new List <MatchFinishedEvent>() { fakeEvent }) .ReturnsAsync(new List <MatchFinishedEvent>()); var mockMatchRepo = new Mock <IMatchRepository>(); var versionRepository = new VersionRepository(MongoClient); var handler = new ReadModelHandler <MatchReadModelHandler>( mockEvents.Object, versionRepository, new MatchReadModelHandler(mockMatchRepo.Object)); await handler.Update(); mockMatchRepo.Verify(m => m.Insert(It.IsAny <Matchup>()), Times.Never); }
public async Task SearchForPlayerAndOppoRace() { var matchRepository = new MatchRepository(MongoClient, new OngoingMatchesCache(MongoClient)); var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent(); var matchFinishedEvent3 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.players[0].race = Race.UD; matchFinishedEvent1.match.players[1].race = Race.HU; matchFinishedEvent2.match.players[0].race = Race.UD; matchFinishedEvent2.match.players[1].race = Race.NE; matchFinishedEvent3.match.players[0].race = Race.OC; matchFinishedEvent3.match.players[1].race = Race.HU; await matchRepository.Insert(Matchup.Create(matchFinishedEvent1)); await matchRepository.Insert(Matchup.Create(matchFinishedEvent2)); var matches = await matchRepository.LoadFor("peter#123", null, GateWay.Europe, GameMode.GM_1v1, Race.UD, Race.HU, 100, 0, 0); var count = await matchRepository.CountFor("peter#123", null, GateWay.Europe, GameMode.GM_1v1, Race.UD, Race.HU, 0); Assert.AreEqual(1, count); Assert.AreEqual(Matchup.Create(matchFinishedEvent1).ToString(), matches.Single().ToString()); }
public async Task PlayerStats_PlayerParticipatedRaceIsCorrect() { var playerRepository = new PlayerRepository(MongoClient); var playerHeroStatsHandler = new PlayerOverallStatsHandler(playerRepository); var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.season = 0; var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent2.match.season = 1; var matchFinishedEvent3 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent3.match.season = 1; await playerHeroStatsHandler.Update(matchFinishedEvent1); await playerHeroStatsHandler.Update(matchFinishedEvent2); await playerHeroStatsHandler.Update(matchFinishedEvent3); var enemyStatsVsPlayerRace = await playerRepository.LoadPlayerProfile(matchFinishedEvent1.match.players[0].battleTag); Assert.AreEqual(2, enemyStatsVsPlayerRace.ParticipatedInSeasons.Count); Assert.AreEqual(1, enemyStatsVsPlayerRace.ParticipatedInSeasons[0].Id); Assert.AreEqual(0, enemyStatsVsPlayerRace.ParticipatedInSeasons[1].Id); }
public async Task LoadAndSave_DifferentMode() { var fakeEvent1 = TestDtoHelper.CreateFakeEvent(); var fakeEvent2 = TestDtoHelper.CreateFakeEvent(); fakeEvent1.match.endTime = 1585701559200; fakeEvent2.match.endTime = 1585701559200; fakeEvent1.match.gameMode = GameMode.GM_1v1; fakeEvent2.match.gameMode = GameMode.GM_2v2; var w3StatsRepo = new W3StatsRepo(MongoClient); var gamesPerDayHandler = new GamesPerDayHandler(w3StatsRepo); await gamesPerDayHandler.Update(fakeEvent1); await gamesPerDayHandler.Update(fakeEvent1); await gamesPerDayHandler.Update(fakeEvent2); var gamesReloaded1 = await w3StatsRepo.LoadGamesPerDay(new DateTime(2020, 4, 1), GameMode.Undefined, GateWay.Europe); var gamesReloaded2 = await w3StatsRepo.LoadGamesPerDay(new DateTime(2020, 4, 1), GameMode.GM_1v1, GateWay.Europe); var gamesReloaded3 = await w3StatsRepo.LoadGamesPerDay(new DateTime(2020, 4, 1), GameMode.GM_2v2, GateWay.Europe); Assert.AreEqual(3, gamesReloaded1.GamesPlayed); Assert.AreEqual(GameMode.Undefined, gamesReloaded1.GameMode); Assert.AreEqual(2, gamesReloaded2.GamesPlayed); Assert.AreEqual(GameMode.GM_1v1, gamesReloaded2.GameMode); Assert.AreEqual(1, gamesReloaded3.GamesPlayed); Assert.AreEqual(GameMode.GM_2v2, gamesReloaded3.GameMode); }
public async Task CountFor() { for (int i = 0; i < 100; i++) { Console.WriteLine($"https://www.test.w3champions.com:{i}/login"); } var matchRepository = new MatchRepository(MongoClient); var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent(); var matchFinishedEvent3 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.season = 1; matchFinishedEvent1.match.players[0].battleTag = "peter#123"; matchFinishedEvent1.match.players[1].battleTag = "wolf#456"; matchFinishedEvent2.match.season = 1; matchFinishedEvent2.match.players[0].battleTag = "wolf#456"; matchFinishedEvent2.match.players[1].battleTag = "peter#123"; matchFinishedEvent3.match.season = 1; matchFinishedEvent3.match.players[0].battleTag = "notFound"; matchFinishedEvent3.match.players[1].battleTag = "notFound2"; var matchup = Matchup.Create(matchFinishedEvent1); await matchRepository.Insert(matchup); await matchRepository.Insert(Matchup.Create(matchFinishedEvent2)); var count = await matchRepository.CountFor(matchup.Teams[0].Players[0].BattleTag); Assert.AreEqual(2, count); }
public async Task PlayerStats_RaceBasedMMR() { var playerRepository = new PlayerRepository(MongoClient); var playerHeroStatsHandler = new PlayOverviewHandler(playerRepository); var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.gateway = GateWay.Europe; matchFinishedEvent2.match.gateway = GateWay.Europe; matchFinishedEvent1.match.gameMode = GameMode.GM_1v1; matchFinishedEvent2.match.gameMode = GameMode.GM_1v1; matchFinishedEvent1.match.season = 2; matchFinishedEvent2.match.season = 2; matchFinishedEvent1.match.players[0].race = Race.NE; matchFinishedEvent2.match.players[0].race = Race.NE; matchFinishedEvent1.match.players[0].battleTag = "peter#123"; matchFinishedEvent2.match.players[0].battleTag = "peter#123"; await playerHeroStatsHandler.Update(matchFinishedEvent1); await playerHeroStatsHandler.Update(matchFinishedEvent2); var enemyStatsVsPlayerRace = await playerRepository.LoadOverview("2_peter#123@20_GM_1v1_NE"); Assert.AreEqual(2, enemyStatsVsPlayerRace.Wins); Assert.AreEqual(0, enemyStatsVsPlayerRace.Losses); }
public async Task LoadDetails_RandomRaceNotSetForNonRandomSelection() { var matchFinishedEvent = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent.match.id = "nmhcCLaRc7"; matchFinishedEvent.Id = ObjectId.GenerateNewId(); // Set race to non-random. matchFinishedEvent.match.players[0].race = Race.HU; matchFinishedEvent.match.players[0].rndRace = null; matchFinishedEvent.result.players[0].raceId = (int)RaceId.HU; matchFinishedEvent.match.players.Find(p => p.battleTag == matchFinishedEvent.result.players[0].battleTag).race = Race.HU; await InsertMatchEvent(matchFinishedEvent); var matchRepository = new MatchRepository(MongoClient, new OngoingMatchesCache(MongoClient)); await matchRepository.Insert(Matchup.Create(matchFinishedEvent)); var result = await matchRepository.LoadDetails(matchFinishedEvent.Id); Assert.AreEqual("nmhcCLaRc7", result.Match.MatchId); Assert.AreEqual(Race.HU, result.Match.Teams[0].Players[0].Race); Assert.AreEqual(null, result.Match.Teams[0].Players[0].RndRace); }
public async Task PlayerMultipleWinRecords() { var playerRepository = new PlayerRepository(MongoClient); var personalSettingsRepo = new PersonalSettingsRepository(MongoClient); var handler = new PlayerOverallStatsHandler(playerRepository, personalSettingsRepo); var handler2 = new PlayerGameModeStatPerGatewayHandler(playerRepository); var handler3 = new PlayerRaceStatPerGatewayHandler(playerRepository); var ev = TestDtoHelper.CreateFakeEvent(); ev.match.gameMode = GameMode.GM_1v1; ev.match.gateway = GateWay.Europe; ev.match.season = 1; ev.match.players[0].battleTag = "peter#123"; ev.match.players[0].battleTag = "peter#123"; ev.match.players[0].race = Race.HU; ev.match.players[1].race = Race.OC; for (int i = 0; i < 100; i++) { await handler.Update(ev); await handler2.Update(ev); await handler3.Update(ev); } var playerLoaded = await playerRepository.LoadRaceStatPerGateway("peter#123", Race.HU, GateWay.Europe, 1); var playerLoadedStats = await playerRepository.LoadGameModeStatPerGateway("peter#123", GateWay.Europe, 1); Assert.AreEqual(100, playerLoadedStats.Single().Wins); Assert.AreEqual(100, playerLoaded.Wins); }
public async Task SearchForPlayerAndOpponent_2v2_SameTeam() { var matchRepository = new MatchRepository(MongoClient, new OngoingMatchesCache(MongoClient)); var matchFinishedEvent1 = TestDtoHelper.CreateFake2v2AtEvent(); var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.season = 1; matchFinishedEvent1.match.players[0].battleTag = "peter#123"; matchFinishedEvent1.match.players[1].battleTag = "wolf#456"; matchFinishedEvent1.match.players[2].battleTag = "LostTeam1#456"; matchFinishedEvent1.match.players[3].battleTag = "LostTeam2#456"; matchFinishedEvent2.match.season = 1; matchFinishedEvent2.match.players[0].battleTag = "peter#123"; matchFinishedEvent2.match.players[1].battleTag = "ANDERER#456"; await matchRepository.Insert(Matchup.Create(matchFinishedEvent1)); await matchRepository.Insert(Matchup.Create(matchFinishedEvent2)); var matches = await matchRepository.LoadFor("peter#123@10", "wolf#456"); var count = await matchRepository.CountFor("peter#123@10", "wolf#456"); Assert.AreEqual(0, count); }
public async Task SearchForPlayerAndOpponent_2v2And1V1() { var matchRepository = new MatchRepository(MongoClient); var matchFinishedEvent1 = TestDtoHelper.CreateFake2v2AtEvent(); var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.season = 1; matchFinishedEvent1.match.players[0].battleTag = "peter#123"; matchFinishedEvent1.match.players[0].team = 0; matchFinishedEvent1.match.players[1].battleTag = "LostTeam1#456"; matchFinishedEvent1.match.players[1].team = 0; matchFinishedEvent1.match.players[2].battleTag = "wolf#456"; matchFinishedEvent1.match.players[2].team = 1; matchFinishedEvent1.match.players[3].battleTag = "LostTeam2#456"; matchFinishedEvent1.match.players[3].team = 1; matchFinishedEvent2.match.season = 1; matchFinishedEvent2.match.players[0].battleTag = "peter#123"; matchFinishedEvent2.match.players[1].battleTag = "wolf#456"; await matchRepository.Insert(Matchup.Create(matchFinishedEvent1)); await matchRepository.Insert(Matchup.Create(matchFinishedEvent2)); var matches = await matchRepository.LoadFor("peter#123", "wolf#456"); var count = await matchRepository.CountFor("peter#123", "wolf#456"); Assert.AreEqual(2, count); Assert.AreEqual("peter#123", matches[0].Teams[0].Players[0].BattleTag); Assert.AreEqual("peter#123", matches[1].Teams[0].Players[0].BattleTag); }
public async Task SearchForPlayerAndOpponent_FilterByGateway() { var matchRepository = new MatchRepository(MongoClient, new OngoingMatchesCache(MongoClient)); var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.gateway = GateWay.America; matchFinishedEvent2.match.gateway = GateWay.Europe; matchFinishedEvent1.match.season = 1; matchFinishedEvent1.match.players[0].battleTag = "peter#123"; matchFinishedEvent1.match.players[1].battleTag = "wolf#456"; matchFinishedEvent2.match.season = 1; matchFinishedEvent2.match.players[0].battleTag = "peter#123"; matchFinishedEvent2.match.players[1].battleTag = "ANDERER#456"; await matchRepository.Insert(Matchup.Create(matchFinishedEvent1)); await matchRepository.Insert(Matchup.Create(matchFinishedEvent2)); var matches = await matchRepository.LoadFor("peter#123", null, GateWay.America); var count = await matchRepository.CountFor("peter#123", null, GateWay.America); Assert.AreEqual(1, count); Assert.AreEqual("peter#123", matches.Single().Teams.First().Players.Single().BattleTag); }
public async Task PlayersFromAn1v1Match_GameModeHandler_Test() { var playerRepository = new PlayerRepository(MongoClient); var handler = new PlayerGameModeStatPerGatewayHandler(playerRepository); var ev = TestDtoHelper.CreateFakeEvent(); ev.match.season = 1; ev.match.players[0].battleTag = "peter#123"; ev.match.players[0].won = true; ev.match.players[1].battleTag = "wolf#456"; ev.match.players[1].won = false; await handler.Update(ev); var winnerStatGateWay = await playerRepository.LoadGameModeStatPerGateway("peter#123", GateWay.Europe, 1); var loser = await playerRepository.LoadGameModeStatPerGateway("wolf#456", GateWay.Europe, 1); Assert.AreEqual(1, winnerStatGateWay.First(x => x.GameMode == GameMode.GM_1v1).Wins); Assert.AreEqual(1, loser.First(x => x.GameMode == GameMode.GM_1v1).Losses); Assert.AreEqual(0, loser.First(x => x.GameMode == GameMode.GM_1v1).Wins); }
public async Task SearchForPlayerAndOpponent_FilterBySeason(int season, string playerTwo) { var matchRepository = new MatchRepository(MongoClient); var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.season = 0; matchFinishedEvent1.match.players[0].battleTag = "peter#123"; matchFinishedEvent1.match.players[1].battleTag = "wolf#456"; matchFinishedEvent2.match.season = 1; matchFinishedEvent2.match.players[0].battleTag = "peter#123"; matchFinishedEvent2.match.players[1].battleTag = "ANDERER#456"; await matchRepository.Insert(Matchup.Create(matchFinishedEvent1)); await matchRepository.Insert(Matchup.Create(matchFinishedEvent2)); var matches = await matchRepository.LoadFor("peter#123", null, season : season); var count = await matchRepository.CountFor("peter#123", null, season : season); Assert.AreEqual(1, count); Assert.AreEqual("peter#123", matches.Single().Teams.First().Players.Single().BattleTag); Assert.AreEqual(playerTwo, matches.Single().Teams.Last().Players.Single().BattleTag); }
public async Task LoadDetails_RandomRaceSetToRandomWhenNullResult() { var matchFinishedEvent = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent.match.id = "nmhcCLaRc7"; matchFinishedEvent.Id = ObjectId.GenerateNewId(); matchFinishedEvent.result = null; var player = matchFinishedEvent.match.players[0]; // Set race to random. matchFinishedEvent.match.players[0].race = Race.RnD; await InsertMatchEvent(matchFinishedEvent); var matchRepository = new MatchRepository(MongoClient, new OngoingMatchesCache(MongoClient)); await matchRepository.Insert(Matchup.Create(matchFinishedEvent)); var result = await matchRepository.LoadDetails(matchFinishedEvent.Id); Assert.AreEqual("nmhcCLaRc7", result.Match.MatchId); Assert.AreEqual(Race.RnD, result.Match.Teams[0].Players.Find(p => p.BattleTag == player.battleTag).Race); Assert.AreEqual(Race.RnD, result.Match.Teams[0].Players.Find(p => p.BattleTag == player.battleTag).RndRace); }
public void MapMatch_Map_Shorter() { var fakeEvent = TestDtoHelper.CreateFakeEvent(); fakeEvent.match.map = "Maps/frozenthrone/(2)terenasstand_lv.w3x"; var matchup = Matchup.Create(fakeEvent); Assert.AreEqual("terenasstand", matchup.Map); }
public void MapMatch_Map() { var fakeEvent = TestDtoHelper.CreateFakeEvent(); fakeEvent.match.map = "Maps/frozenthrone/community/(2)amazonia.w3x"; var matchup = Matchup.Create(fakeEvent); Assert.AreEqual("amazonia", matchup.Map); }
public void MapMatch_GameMode() { var fakeEvent = TestDtoHelper.CreateFakeEvent(); fakeEvent.match.gameMode = GameMode.GM_1v1; var matchup = Matchup.Create(fakeEvent); Assert.AreEqual(GameMode.GM_1v1, matchup.GameMode); }
public async Task PlayerStats_LoadMMRsByValidEnumValues() { var testing_season = 0; var playerRepository = new PlayerRepository(MongoClient); var playOverviewHandler = new PlayOverviewHandler(playerRepository); var mmrDistributionHandler = new MmrDistributionHandler(playerRepository); var gateWayValues = Enum.GetValues(typeof(GateWay)); var gameModeValues = Enum.GetValues(typeof(GameMode)); foreach (GateWay gateWay in gateWayValues) { //skip undefinded value of ENums if (gateWay == GateWay.Undefined) { continue; } foreach (GameMode gameMode in gameModeValues) { if (gameMode == GameMode.Undefined || gameMode == GameMode.GM_2v2 || gameMode == GameMode.GM_2v2_AT || gameMode == GameMode.GM_4v4 || gameMode == GameMode.GM_4v4_AT || gameMode == GameMode.GM_LEGION_4v4_x20 || gameMode == GameMode.GM_LEGION_4v4_x20_AT) { continue; } var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.players[0].battleTag = "peter#123"; matchFinishedEvent1.match.season = testing_season; matchFinishedEvent1.match.players[0].race = Race.HU; matchFinishedEvent1.match.gateway = gateWay; matchFinishedEvent1.match.gameMode = gameMode; var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent2.match.players[0].battleTag = "peter#123"; matchFinishedEvent2.match.season = testing_season; matchFinishedEvent2.match.players[0].race = Race.NE; matchFinishedEvent2.match.gateway = gateWay; matchFinishedEvent2.match.gameMode = gameMode; await playOverviewHandler.Update(matchFinishedEvent1); await playOverviewHandler.Update(matchFinishedEvent2); var distribution = await mmrDistributionHandler.GetDistributions(testing_season, gateWay, gameMode); Assert.IsNotNull(distribution); } } }
public void MapMatch_StartTime() { var fakeEvent = TestDtoHelper.CreateFakeEvent(); var matchup = Matchup.Create(fakeEvent); fakeEvent.match.startTime = 1585692028740; fakeEvent.match.endTime = 1585692047363; Assert.IsNotNull(matchup.StartTime); Assert.IsNotNull(matchup.EndTime); }
public void MapMatch_TimeSpan() { var fakeEvent = TestDtoHelper.CreateFakeEvent(); fakeEvent.match.startTime = 1585692028740; fakeEvent.match.endTime = 1585692047363; var matchup = Matchup.Create(fakeEvent); Assert.AreEqual(0, matchup.Duration.Minutes); Assert.AreEqual(18, matchup.Duration.Seconds); Assert.AreEqual(623, matchup.Duration.Milliseconds); }
public async Task SearchForGameMode2v2_LoadDefault() { var matchRepository = new MatchRepository(MongoClient); var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.gameMode = GameMode.GM_2v2_AT; await matchRepository.Insert(Matchup.Create(matchFinishedEvent1)); var matches = await matchRepository.Load(); Assert.AreEqual(1, matches.Count); }
public async Task SearchForGameMode2v2_NotFound() { var matchRepository = new MatchRepository(MongoClient); var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.gameMode = GameMode.GM_1v1; await matchRepository.Insert(Matchup.Create(matchFinishedEvent1)); var matches = await matchRepository.Load(GateWay.Undefined, GameMode.GM_2v2_AT); Assert.AreEqual(0, matches.Count); }
public async Task LoadDetails_NotDetailsAvailable() { var matchFinishedEvent = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent.match.id = "nmhcCLaRc7"; matchFinishedEvent.Id = ObjectId.GenerateNewId(); var matchRepository = new MatchRepository(MongoClient); await matchRepository.Insert(Matchup.Create(matchFinishedEvent)); var result = await matchRepository.LoadDetails(matchFinishedEvent.Id); Assert.AreEqual("nmhcCLaRc7", result.Match.MatchId); }
public async Task Upsert() { var matchRepository = new MatchRepository(MongoClient); var matchFinishedEvent = TestDtoHelper.CreateFakeEvent(); await matchRepository.Insert(Matchup.Create(matchFinishedEvent)); await matchRepository.Insert(Matchup.Create(matchFinishedEvent)); var matches = await matchRepository.Load(); Assert.AreEqual(1, matches.Count); }
public async Task TestThatNewVersionIsUpdated() { var fakeEvent1 = TestDtoHelper.CreateFakeEvent(); var fakeEvent2 = TestDtoHelper.CreateFakeEvent(); var fakeEvent3 = TestDtoHelper.CreateFakeEvent(); var fakeEvent4 = TestDtoHelper.CreateFakeEvent(); var fakeEvent5 = TestDtoHelper.CreateFakeEvent(); fakeEvent1.match.season = 0; fakeEvent1.match.startTime = 5000; fakeEvent1.Id = ObjectId.GenerateNewId(); fakeEvent2.match.season = 0; fakeEvent2.match.startTime = 4000; fakeEvent2.Id = ObjectId.GenerateNewId(); fakeEvent3.match.season = 1; fakeEvent3.match.startTime = 3000; fakeEvent3.Id = ObjectId.GenerateNewId(); fakeEvent4.match.season = 1; fakeEvent4.match.startTime = 2000; fakeEvent4.match.id = "Test"; fakeEvent4.Id = ObjectId.GenerateNewId(); fakeEvent5.match.season = 0; fakeEvent5.match.startTime = 1000; fakeEvent5.Id = ObjectId.GenerateNewId(); await InsertMatchEvents(new List <MatchFinishedEvent> { fakeEvent1, fakeEvent2, fakeEvent3, fakeEvent4, fakeEvent5 }); var matchRepository = new MatchRepository(MongoClient, new OngoingMatchesCache(MongoClient)); var versionRepository = new VersionRepository(MongoClient); var handler = new ReadModelHandler <MatchReadModelHandler>( new MatchEventRepository(MongoClient), versionRepository, new MatchReadModelHandler(matchRepository)); await handler.Update(); var version = await versionRepository.GetLastVersion <MatchReadModelHandler>(); var matches = await matchRepository.Load(); Assert.AreEqual(1, version.Season); Assert.AreEqual(fakeEvent5.Id.ToString(), version.Version); Assert.AreEqual(4, matches.Count); Assert.AreEqual(fakeEvent4.match.id, matches[0].MatchId); Assert.AreEqual(fakeEvent4.Id, matches[0].Id); }
public async Task LoadAndSave() { var matchRepository = new MatchRepository(MongoClient, new OngoingMatchesCache(MongoClient)); var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent(); await matchRepository.Insert(Matchup.Create(matchFinishedEvent1)); await matchRepository.Insert(Matchup.Create(matchFinishedEvent2)); var matches = await matchRepository.Load(); Assert.AreEqual(2, matches.Count); }
public async Task RaceVsRaceOnMapStatsTest_GroupByMMR() { var fakeEvent1 = TestDtoHelper.CreateFakeEvent(); var fakeEvent2 = TestDtoHelper.CreateFakeEvent(); fakeEvent1.match.players[0].mmr.rating = 1300; fakeEvent1.match.players[1].mmr.rating = 1300; fakeEvent1.match.startTime = 1591374182684; fakeEvent2.match.players[0].mmr.rating = 1800; fakeEvent2.match.players[1].mmr.rating = 1900; fakeEvent2.match.startTime = 1591370203764; await InsertMatchEvents(new List <MatchFinishedEvent> { fakeEvent1, fakeEvent2 }); var w3StatsRepo = new W3StatsRepo(MongoClient); var patchRepo = new PatchRepository(MongoClient); var patch1 = new Patch { Version = "1.32.5", StartDate = DateTime.SpecifyKind(new DateTime(2020, 4, 27, 0, 0, 0), DateTimeKind.Utc) }; var patch2 = new Patch { Version = "1.32.6", StartDate = DateTime.SpecifyKind(new DateTime(2020, 6, 3, 19, 0, 0), DateTimeKind.Utc) }; await patchRepo.InsertPatches(new List <Patch>() { patch1, patch2 }); var overallRaceAndWinStatsHandler = new OverallRaceAndWinStatHandler(w3StatsRepo, patchRepo); await overallRaceAndWinStatsHandler.Update(fakeEvent1); await overallRaceAndWinStatsHandler.Update(fakeEvent2); var result = await w3StatsRepo.LoadRaceVsRaceStats(); Assert.AreEqual(3, result.Count); Assert.AreEqual(0, result[0].MmrRange); Assert.AreEqual(1200, result[1].MmrRange); Assert.AreEqual(1800, result[2].MmrRange); }
public async Task LoadAndSavePersistsDateTimeInfo() { var fakeEvent = TestDtoHelper.CreateFakeEvent(); fakeEvent.match.endTime = 1585701559200; var w3StatsRepo = new W3StatsRepo(MongoClient); var gamesPerDay = new GamesPerDayHandler(w3StatsRepo); await gamesPerDay.Update(fakeEvent); await gamesPerDay.Update(fakeEvent); var gamesReloaded = await w3StatsRepo.LoadGamesPerDay(new DateTime(2020, 4, 1), GameMode.Undefined, GateWay.Europe); Assert.AreEqual(2, gamesReloaded.GamesPlayed); }
private static MatchFinishedEvent CreateMatchEvent( PlayerMMrChange player, List <Hero> playerHeroes, PlayerMMrChange enemyPlayer, List <Hero> enemyHeroes) { var matchFinishedEvent = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent.match.players[0] = player; matchFinishedEvent.result.players[0].heroes = playerHeroes; matchFinishedEvent.match.players[1] = enemyPlayer; matchFinishedEvent.result.players[1].heroes = enemyHeroes; return(matchFinishedEvent); }
public async Task LoadAndSave() { var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent1.match.id = "nmhcCLaRc7"; await InsertMatchEvent(matchFinishedEvent1); var matchEventRepository = new MatchEventRepository(MongoClient); await matchEventRepository.InsertIfNotExisting(matchFinishedEvent1); var events = await matchEventRepository.Load(); Assert.AreEqual(1, events.Count); Assert.AreEqual(false, events[0].WasFromSync); }