示例#1
0
 private static List <Guid> GetMatchEventsIds(Player player, MatchEvents type)
 {
     return(player.MatchEvents
            .Select(mId => MatchEventRepository.GetInstance().FindById(mId))
            .Where(matchEvent => matchEvent.GetType() == type)
            .Select(mEvent => mEvent.Id).ToList());
 }
示例#2
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();
        }
示例#3
0
        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);
        }
示例#4
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)));
        }
示例#5
0
        public async Task LoadStartedIgnoresEventThatAreYoungerThan20Seconds()
        {
            var startEvent1 = TestDtoHelper.CreateFakeStartedEvent();
            var startEvent2 = TestDtoHelper.CreateFakeStartedEvent();

            startEvent1.Id       = ObjectId.GenerateNewId(DateTime.Now.AddDays(-1));
            startEvent1.match.id = "test";
            startEvent2.Id       = ObjectId.GenerateNewId(DateTime.Now);

            await InsertMatchStartedEvent(startEvent1);
            await InsertMatchStartedEvent(startEvent2);

            var matchEventRepository = new MatchEventRepository(MongoClient);

            var events = await matchEventRepository.LoadStartedMatches();

            Assert.AreEqual(1, events.Count);
            Assert.AreEqual(startEvent1.match.id, events[0].match.id);
        }
示例#6
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);
        }
示例#7
0
        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);
        }
示例#8
0
 public MatchEventService()
 {
     _matchEventRepository = MatchEventRepository.GetInstance();
 }
 public void Remove(MatchEvent matchEvent)
 {
     MatchEventRepository.Remove(matchEvent);
 }
 public void Add(MatchEvent matchEvent)
 {
     MatchEventRepository.Add(matchEvent);
 }