Exemple #1
0
        public void Can_Retrieve_Match_ForPC()
        {
            var region       = PubgRegion.PCEurope;
            var samples      = Storage.GetSamples(region);
            var matchService = new PubgMatchService(Storage.ApiKey);

            var match = matchService.GetMatch(region, samples.MatchIds.FirstOrDefault());

            match.ShardId.Should().Equals(region.Serialize());
            match.Rosters.Should().NotBeNull();
            match.GameMode.Should().NotBeNullOrWhiteSpace();

            Assert.All(match.Rosters, r => r.Stats.Rank.Should().BeGreaterThan(0));
            match.Rosters.Should().ContainSingle(x => x.Won == true);

            var participants = match.Rosters.SelectMany(x => x.Participants);

            participants.Should().NotBeNullOrEmpty();

            Assert.All(participants, p => p.Stats.Should().NotBeNull());
            Assert.All(participants, p => p.Stats.KillPlace.Should().BeGreaterThan(0));
            Assert.All(participants, p => p.Stats.WinPlace.Should().BeGreaterThan(0));
            Assert.All(participants, p => p.ShardId.Should().Equals(region.Serialize()));
            Assert.All(participants, p => p.Id.Should().NotBeNullOrWhiteSpace());
        }
Exemple #2
0
        public static async Task <Match> GetPubgMatch(string matchID)
        {
            var service = new PubgMatchService();
            var match   = await service.GetMatchAsync(PubgPlatform.Steam, matchID, Config.PubgToken);

            string serialized = JsonConvert.SerializeObject(match);
            var    m          = JsonConvert.DeserializeObject <Match>(serialized);

            return(m);
        }
Exemple #3
0
        public static Match GetPubgMatch(string matchID)
        {
            var service = new PubgMatchService();
            var match   = service.GetMatch(matchID, Credentials.PubgToken);

            string serialized = JsonConvert.SerializeObject(match);
            var    m          = JsonConvert.DeserializeObject <Match>(serialized);

            return(m);
        }
Exemple #4
0
        public static PubgMatch GetMatch(PubgRegion region)
        {
            var match = StoredItems.OfType <PubgMatch>().FirstOrDefault(p => p.ShardId == region.Serialize());

            if (match != null)
            {
                return(match);
            }

            var samples = GetSamples(region);

            match = new PubgMatchService(ApiKey).GetMatch(region, samples.MatchIds.First());

            StoredItems.Add(match);

            return(match);
        }
Exemple #5
0
        public static PubgMatch GetMatch(PubgPlatform platform)
        {
            var match = StoredItems.OfType <PubgMatch>().FirstOrDefault(p => p.ShardId == platform.Serialize());

            if (match != null)
            {
                return(match);
            }

            var samples      = GetSamples(platform);
            var matchService = new PubgMatchService(ApiKey);

            match = matchService.GetMatch(platform, samples.MatchIds.First());

            StoredItems.Add(match);

            return(match);
        }
Exemple #6
0
        public static PubgMatch GetMatch(PubgPlatform platform)
        {
            var match = StoredItems.OfType<PubgMatch>().FirstOrDefault(p => p.ShardId == platform.Serialize());

            if (match != null)
                return match;

            var region = platform == PubgPlatform.Xbox ? PubgRegion.XboxEurope : PubgRegion.PCEurope;

            var samples = GetSamples(region);
            var matchService = new PubgMatchService(ApiKey);

            match = matchService.GetMatch(platform, samples.MatchIds.First());

            StoredItems.Add(match);

            return match;
        }
Exemple #7
0
        public void Can_Retrieve_Match()
        {
            var region       = PubgRegion.PCEurope;
            var samples      = Storage.GetSamples(region);
            var matchService = new PubgMatchService(Storage.ApiKey);

            var match = matchService.GetMatch(region, samples.MatchIds.FirstOrDefault());

            match.ShardId.Should().Equals(region.Serialize());
            match.Rosters.Should().NotBeNull();

            var participants = match.Rosters.SelectMany(x => x.Participants);

            participants.Should().NotBeNullOrEmpty();

            Assert.All(participants, p => p.Stats.Should().NotBeNull());
            Assert.All(participants, p => p.ShardId.Should().Equals(region.Serialize()));
            Assert.All(participants, p => p.Id.Should().NotBeNullOrWhiteSpace());
        }
Exemple #8
0
        public void Can_Retrieve_Match_ForXbox()
        {
            var samples      = Storage.GetSamples(PubgPlatform.Xbox);
            var matchService = new PubgMatchService(Storage.ApiKey);

            var match = matchService.GetMatch(PubgPlatform.Xbox, samples.MatchIds.FirstOrDefault());

            match.Rosters.Should().NotBeNull();

            Assert.All(match.Rosters, r => r.Stats.Rank.Should().BeGreaterThan(0));
            match.Rosters.Should().ContainSingle(x => x.Won == true);

            var participants = match.Rosters.SelectMany(x => x.Participants);

            participants.Should().NotBeNullOrEmpty();

            Assert.All(participants, p => p.Stats.Should().NotBeNull());
            Assert.All(participants, p => p.Stats.KillPlace.Should().BeGreaterThan(0));
            Assert.All(participants, p => p.Stats.WinPlace.Should().BeGreaterThan(0));
            Assert.All(participants, p => p.Id.Should().NotBeNullOrWhiteSpace());
        }
Exemple #9
0
        private PubgMatch GetMatch(PubgPlatform platform)
        {
            var       matchService = new PubgMatchService();
            PubgMatch match;

            try
            {
                match = matchService.GetMatch(platform, myOptions.MatchId);
            }
            catch (PubgNotFoundException)               //when ( e.HttpStatusCode == HttpStatusCode.NotFound )
            {
                // Errorcode not set, we wont parse strings though!
                Console.WriteLine($"Can not find match. (Id = {myOptions.MatchId})");
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Can not process match. (Id = {myOptions.MatchId})");
                Console.WriteLine(e.Message);
                return(null);
            }

            return(match);
        }
Exemple #10
0
        private static async Task <PubgMatch> GetMatchFromApiAsync(string matchId, PubgPlatform platform)
        {
            PubgMatchService service = new PubgMatchService();

            return(await service.GetMatchAsync(platform, matchId));
        }