Beispiel #1
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();
        }
Beispiel #2
0
        public async Task OnlyOneRankIsSyncedBecausePreviousWasSynced()
        {
            var matchEventRepository = new MatchEventRepository(MongoClient);
            var rankRepository       = new Mock <IRankRepository>();
            var rankHandler          = new RankSyncHandler(rankRepository.Object, matchEventRepository);

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

            await rankHandler.Update();

            rankRepository.Verify(r => r.InsertRanks(It.Is <List <Rank> >(rl => rl.Count == 1)));

            await InsertRankChangedEvent(TestDtoHelper.CreateRankChangedEvent("wolf#456"));

            await rankHandler.Update();

            rankRepository.Verify(r => r.InsertRanks(It.Is <List <Rank> >(rl => rl.Count == 1)));
        }
Beispiel #3
0
        public async Task RaceBasedMMRUpdate()
        {
            var matchEventRepository = new MatchEventRepository(MongoClient);
            var rankRepository       = new RankRepository(MongoClient);
            var playerRepository     = new PlayerRepository(MongoClient);

            var matchFinishedEvent  = TestDtoHelper.CreateFakeEvent();
            var rankingChangedEvent = TestDtoHelper.CreateRankChangedEvent();

            matchFinishedEvent.match.players[0].battleTag = "peTer#123";
            matchFinishedEvent.match.players[0].race      = Race.NE;
            matchFinishedEvent.match.gameMode             = GameMode.GM_1v1;
            matchFinishedEvent.match.season  = 2;
            matchFinishedEvent.match.gateway = GateWay.America;

            rankingChangedEvent.ranks[0].battleTags = new List <string> {
                "peTer#123"
            };
            rankingChangedEvent.ranks[0].race = Race.NE;
            rankingChangedEvent.gateway       = GateWay.America;
            rankingChangedEvent.gameMode      = GameMode.GM_1v1;
            rankingChangedEvent.season        = 2;

            await InsertRankChangedEvent(rankingChangedEvent);

            await matchEventRepository.InsertIfNotExisting(matchFinishedEvent);

            var playOverviewHandler = new PlayOverviewHandler(playerRepository);
            await playOverviewHandler.Update(matchFinishedEvent);

            var rankHandler = new RankSyncHandler(rankRepository, matchEventRepository);

            await playOverviewHandler.Update(matchFinishedEvent);

            await rankHandler.Update();

            var rank = await rankRepository.SearchPlayerOfLeague("peT", 2, GateWay.America, GameMode.GM_1v1);

            Assert.AreEqual(1, rank.Count);
            Assert.AreEqual(Race.NE, rank[0].Race);
        }
        public async Task RankIntegrationWithMultipleIds()
        {
            var matchEventRepository = new MatchEventRepository(MongoClient);
            var rankRepository       = new RankRepository(MongoClient, personalSettingsProvider);
            var playerRepository     = new PlayerRepository(MongoClient);

            var matchFinishedEvent  = TestDtoHelper.CreateFakeEvent();
            var rankingChangedEvent = TestDtoHelper.CreateRankChangedEvent();

            matchFinishedEvent.match.players[0].battleTag = "peTer#123";
            matchFinishedEvent.match.gameMode             = GameMode.GM_1v1;
            matchFinishedEvent.match.gateway = GateWay.America;

            rankingChangedEvent.ranks[0].battleTags = new List <string> {
                "peTer#123"
            };
            rankingChangedEvent.gateway  = GateWay.America;
            rankingChangedEvent.gameMode = GameMode.GM_1v1;

            await InsertRankChangedEvent(rankingChangedEvent);

            await matchEventRepository.InsertIfNotExisting(matchFinishedEvent);

            var playOverviewHandler = new PlayOverviewHandler(playerRepository);
            await playOverviewHandler.Update(matchFinishedEvent);

            var rankHandler = new RankSyncHandler(rankRepository, matchEventRepository);

            await playOverviewHandler.Update(matchFinishedEvent);

            await rankHandler.Update();

            var rank = await rankRepository.SearchPlayerOfLeague("peT", 0, GateWay.America, GameMode.GM_1v1);

            Assert.AreEqual(1, rank.Count);
        }