コード例 #1
0
        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);
        }