Example #1
0
        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 Cache_ByPlayerId_OneTeamEmpty()
        {
            var matchRepository = new MatchRepository(MongoClient, new OngoingMatchesCache(MongoClient));

            var storedEvent = TestDtoHelper.Create1v1StartedEvent();

            await matchRepository.InsertOnGoingMatch(OnGoingMatchup.Create(storedEvent));

            await Task.Delay(100);

            var result = await matchRepository.TryLoadOnGoingMatchForPlayer(storedEvent.match.players[0].battleTag);

            Assert.IsNotNull(result);
            Assert.AreEqual(storedEvent.match.id, result.MatchId);

            var notCachedEvent = TestDtoHelper.Create1v1StartedEvent();
            await matchRepository.InsertOnGoingMatch(OnGoingMatchup.Create(notCachedEvent));

            await Task.Delay(100);

            var result2 = await matchRepository.TryLoadOnGoingMatchForPlayer(storedEvent.match.players[0].battleTag);

            Assert.IsNotNull(result2);
            Assert.AreEqual(storedEvent.match.id, result.MatchId);
            Assert.AreEqual(notCachedEvent.match.id, result2.MatchId);
        }
Example #3
0
        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 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 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);
        }
Example #6
0
        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 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);
        }
Example #8
0
        public async Task UpdateOverview_HandlerUpdate_2v2RT()
        {
            var matchFinishedEvent  = TestDtoHelper.CreateFake2v2RTEvent();
            var playerRepository    = new PlayerRepository(MongoClient);
            var playOverviewHandler = new PlayOverviewHandler(playerRepository);

            await playOverviewHandler.Update(matchFinishedEvent);

            var winners = matchFinishedEvent.match.players.Where(x => x.won);

            Assert.AreEqual(2, winners.Count());

            foreach (var player in winners)
            {
                var playerProfile = await playerRepository.LoadOverview($"0_{player.battleTag}@20_GM_2v2");

                Assert.AreEqual(1, playerProfile.Wins);
                Assert.AreEqual(0, playerProfile.Losses);
                Assert.AreEqual(GameMode.GM_2v2, playerProfile.GameMode);
            }

            var losers = matchFinishedEvent.match.players.Where(x => !x.won);

            Assert.AreEqual(2, losers.Count());

            foreach (var player in losers)
            {
                var playerProfile = await playerRepository.LoadOverview($"0_{player.battleTag}@20_GM_2v2");

                Assert.AreEqual(0, playerProfile.Wins);
                Assert.AreEqual(1, playerProfile.Losses);
                Assert.AreEqual(GameMode.GM_2v2, playerProfile.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 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);
        }
Example #11
0
        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);
        }
Example #12
0
        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 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 Cache_AllOngoingMatches()
        {
            var matchRepository = new MatchRepository(MongoClient, new OngoingMatchesCache(MongoClient));

            var storedEvent = TestDtoHelper.CreateFakeStartedEvent();
            await matchRepository.InsertOnGoingMatch(OnGoingMatchup.Create(storedEvent));

            await Task.Delay(100);

            var result = await matchRepository.LoadOnGoingMatches(
                storedEvent.match.gameMode,
                storedEvent.match.gateway);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(storedEvent.match.id, result[0].MatchId);

            var notCachedEvent = TestDtoHelper.CreateFakeStartedEvent();
            await matchRepository.InsertOnGoingMatch(OnGoingMatchup.Create(notCachedEvent));

            await Task.Delay(100);

            var result2 = await matchRepository.LoadOnGoingMatches(
                notCachedEvent.match.gameMode,
                notCachedEvent.match.gateway);

            Assert.AreEqual(2, result2.Count);
            Assert.AreEqual(storedEvent.match.id, result[0].MatchId);
        }
Example #15
0
        public async Task UpdateOverview_HandlerUpdate_FootmenFrenzy()
        {
            var matchFinishedEvent = TestDtoHelper.CreateFakeFootmenFrenzyEvent();

            var playerRepository = new PlayerRepository(MongoClient);
            var handler          = new PlayerGameModeStatPerGatewayHandler(playerRepository);

            await handler.Update(matchFinishedEvent);

            var winners = matchFinishedEvent.match.players.Where(x => x.won);

            Assert.AreEqual(3, winners.Count());

            foreach (var player in winners)
            {
                var winnerStatGateWay = await playerRepository.LoadGameModeStatPerGateway(player.battleTag, GateWay.Europe, matchFinishedEvent.match.season);

                Assert.AreEqual(1, winnerStatGateWay.First(x => x.GameMode == GameMode.GM_FOOTMEN_FRENZY).Wins);
                Assert.AreEqual(0, winnerStatGateWay.First(x => x.GameMode == GameMode.GM_FOOTMEN_FRENZY).Losses);
            }

            var losers = matchFinishedEvent.match.players.Where(x => !x.won);

            Assert.AreEqual(9, losers.Count());

            foreach (var player in losers)
            {
                var winnerStatGateWay = await playerRepository.LoadGameModeStatPerGateway(player.battleTag, GateWay.Europe, matchFinishedEvent.match.season);

                Assert.AreEqual(0, winnerStatGateWay.First(x => x.GameMode == GameMode.GM_FOOTMEN_FRENZY).Wins);
                Assert.AreEqual(1, winnerStatGateWay.First(x => x.GameMode == GameMode.GM_FOOTMEN_FRENZY).Losses);
            }
        }
        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 PlayersFromAn2v2ATMatch_GameModeHandler_Test()
        {
            var playerRepository = new PlayerRepository(MongoClient);
            var handler          = new PlayerGameModeStatPerGatewayHandler(playerRepository);

            var ev = TestDtoHelper.CreateFake2v2AtEvent();

            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       = true;

            ev.match.players[2].battleTag = "TEAM2#123";
            ev.match.players[2].won       = false;

            ev.match.players[3].battleTag = "TEAM2#456";
            ev.match.players[3].won       = false;

            await handler.Update(ev);

            var winners = await playerRepository.LoadGameModeStatPerGateway("1_peter#123@10_wolf#456@10_GM_2v2_AT", GateWay.America, 1);

            var losers = await playerRepository.LoadGameModeStatPerGateway("1_TEAM2#123@10_TEAM2#456@10_GM_2v2_AT", GateWay.America, 1);

            Assert.AreEqual(1, winners.First(x => x.GameMode == GameMode.GM_2v2_AT).Wins);
            Assert.AreEqual(0, winners.First(x => x.GameMode == GameMode.GM_2v2_AT).Losses);

            Assert.AreEqual(1, losers.First(x => x.GameMode == GameMode.GM_2v2_AT).Losses);
            Assert.AreEqual(0, losers.First(x => x.GameMode == GameMode.GM_2v2_AT).Wins);
        }
        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);
        }
Example #20
0
        public async Task TestPatchVersionAgainstMatchStartDate([ValueSource("_testData")] TestData testData)
        {
            var patchRepository = new PatchRepository(MongoClient);
            var patches         = TestDtoHelper.CreateFakePatches();
            await patchRepository.InsertPatches(patches);

            Assert.AreEqual(await patchRepository.GetPatchVersionFromDate(testData.StartDate), testData.ExpectedResult);
        }
        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_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_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);
        }
Example #26
0
        public async Task EmptyRanksDoesNotThrwoBulkWriteException()
        {
            var matchEventRepository = new MatchEventRepository(MongoClient);
            var rankHandler          = new RankSyncHandler(new RankRepository(MongoClient), matchEventRepository);

            await InsertRankChangedEvent(TestDtoHelper.CreateRankChangedEvent("peter#123"));

            await rankHandler.Update();

            await rankHandler.Update();
        }
        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 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);
        }