예제 #1
0
        public async Task PlayersFromAn2v2ATMatch_GameModeHandler_Test()
        {
            var playerRepository = new PlayerRepository(MongoClient);
            var handler          = new PlayerGameModeStatPerGatewayHandler(playerRepository);

            var ev = TestDtoHelper.CreateFake2v2Event();

            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.CreateFake2v2Event();
            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);
        }
예제 #3
0
        public async Task UpdateOverview_HandlerUpdate_2v2AT()
        {
            var matchFinishedEvent  = TestDtoHelper.CreateFake2v2Event();
            var playerRepository    = new PlayerRepository(MongoClient);
            var playOverviewHandler = new PlayOverviewHandler(playerRepository);

            matchFinishedEvent.match.players[0].battleTag = "peter#123";
            matchFinishedEvent.match.players[1].battleTag = "wolf#123";
            matchFinishedEvent.match.gateway  = GateWay.America;
            matchFinishedEvent.match.gameMode = GameMode.GM_2v2_AT;

            await playOverviewHandler.Update(matchFinishedEvent);

            var playerProfile = await playerRepository.LoadOverview("0_peter#123@10_wolf#123@10_GM_2v2_AT");

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