Пример #1
0
        public void GetConstructedUri_NoParameters_MatchesExpected()
        {
            var query = new GetMatchEvents();

            var uri = query.GetConstructedUri();

            Assert.AreEqual("stats/h5/matches//events", uri);
        }
Пример #2
0
        public async Task GetMatchEvents_MissingGuid()
        {
            var query = new GetMatchEvents();

            await Global.Session.Query(query);

            Assert.Fail("An exception should have been thrown");
        }
Пример #3
0
        public void GetConstructedUri_NoParameters_MatchesExpected()
        {
            var query = new GetMatchEvents();

            var uri = query.GetConstructedUri();

            Assert.AreEqual("stats/h5/matches//events", uri);
        }
Пример #4
0
        public async Task GetMatchEvents_DoesNotThrow(string guid)
        {
            var query = new GetMatchEvents(new Guid(guid))
                        .SkipCache();

            var result = await Global.Session.Query(query);

            Assert.IsInstanceOf(typeof(MatchEventSummary), result);
        }
Пример #5
0
        public void GetConstructedUri_ForMatchId_MatchesExpected(string guid)
        {
            var query = new GetMatchEvents()
                .ForMatchId(new Guid(guid));

            var uri = query.GetConstructedUri();

            Assert.AreEqual($"stats/h5/matches/{guid}/events", uri);
        }
Пример #6
0
        public void GetConstructedUri_ForMatchId_MatchesExpected(string guid)
        {
            var query = new GetMatchEvents()
                        .ForMatchId(new Guid(guid));

            var uri = query.GetConstructedUri();

            Assert.AreEqual($"stats/h5/matches/{guid}/events", uri);
        }
Пример #7
0
        public async Task GetMatchEvents_IsSerializable(string guid)
        {
            var query = new GetMatchEvents(new Guid(guid))
                        .SkipCache();

            var result = await Global.Session.Query(query);

            SerializationUtility <MatchEventSummary> .AssertRoundTripSerializationIsPossible(result);
        }
Пример #8
0
        public async Task GetMatchEvents_DoesNotThrow(string guid)
        {
            var query = new GetMatchEvents()
                .ForMatchId(new Guid(guid))
                .SkipCache();

            var result = await Global.Session.Query(query);

            Assert.IsInstanceOf(typeof(MatchEvents), result);
        }
Пример #9
0
        public async Task Query_DoesNotThrow(string guid)
        {
            var query = new GetMatchEvents(new Guid(guid))
                        .SkipCache();

            var result = await _mockSession.Query(query);

            Assert.IsInstanceOf(typeof(MatchEventSummary), result);
            Assert.AreEqual(_matchEventSummary, result);
        }
Пример #10
0
        public async Task Query_DoesNotThrow()
        {
            var query = new GetMatchEvents()
                .ForMatchId(Guid.Empty)
                .SkipCache();

            var result = await _mockSession.Query(query);

            Assert.IsInstanceOf(typeof(MatchEvents), result);
            Assert.AreEqual(_matchEvents, result);
        }
Пример #11
0
        public async Task Query_DoesNotThrow()
        {
            var query = new GetMatchEvents()
                        .ForMatchId(Guid.Empty)
                        .SkipCache();

            var result = await _mockSession.Query(query);

            Assert.IsInstanceOf(typeof(MatchEvents), result);
            Assert.AreEqual(_matchEvents, result);
        }
Пример #12
0
        public static void Validate(this GetMatchEvents getMatchEvents)
        {
            var validationResult = new ValidationResult();

            if (string.IsNullOrWhiteSpace(getMatchEvents.MatchId))
            {
                validationResult.Messages.Add("GetMatchEvents query requires a MatchId to be set.");
            }

            if (!validationResult.Success)
            {
                throw new ValidationException(validationResult.Messages);
            }
        }
Пример #13
0
        public async Task <MatchEvents> GetEventsForMatch(Guid id)
        {
            //var data = await _db.FindAsync<MatchEventsData>(id.ToString());
            //if (data == null)
            //{
            var query = new GetMatchEvents().ForMatchId(id);
            var match = await _session.Query(query);

            //match.GameEvents.RemoveAll(e => e.EventName != Enumeration.EventType.Death);
            //data = new MatchEventsData(id, match);
            //_db.InsertAsync(data);
            return(match);
            //}
            //return data.Deserialize();
        }
Пример #14
0
        public async Task GetMatchEvents_SchemaIsValid(string guid)
        {
            var weaponsSchema = JSchema.Parse(File.ReadAllText(Halo5Config.MatchEventsJsonSchemaPath), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri  = new Uri(Path.GetFullPath(Halo5Config.MatchEventsJsonSchemaPath))
            });

            var query = new GetMatchEvents(new Guid(guid))
                        .SkipCache();

            var jArray = await Global.Session.Get <JObject>(query.Uri);

            SchemaUtility.AssertSchemaIsValid(weaponsSchema, jArray);
        }
Пример #15
0
        public async Task GetMatchEvents_SchemaIsValid(string guid)
        {
            var jSchema = JSchema.Parse(File.ReadAllText(Schema), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri  = new Uri(Path.GetFullPath(Schema))
            });

            var matchId = new Guid(guid);

            var query = new GetMatchEvents(matchId)
                        .SkipCache();

            var jArray = await Global.Session.Get <JObject>(query.Uri);

            SchemaUtility.AssertSchemaIsValid(jSchema, jArray);
        }
Пример #16
0
        public async Task GetMatchEvents_ModelMatchesSchema(string guid)
        {
            var schema = JSchema.Parse(File.ReadAllText(Halo5Config.MatchEventsJsonSchemaPath), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri  = new Uri(Path.GetFullPath(Halo5Config.MatchEventsJsonSchemaPath))
            });

            var query = new GetMatchEvents(new Guid(guid))
                        .SkipCache();

            var result = await Global.Session.Query(query);

            var json       = JsonConvert.SerializeObject(result);
            var jContainer = JsonConvert.DeserializeObject <JContainer>(json);

            SchemaUtility.AssertSchemaIsValid(schema, jContainer);
        }
Пример #17
0
        public async Task <MatchEvents> GetEventsForMatch(Guid id)
        {
            var data = await _db.FindAsync <MatchEventsData>(id.ToString());

            if (data == null)
            {
                var query = new GetMatchEvents().ForMatchId(id);
                var match = await _session.Query(query);

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

                data = new MatchEventsData(id, match);
                _db.InsertAsync(data);
                return(match);
            }
            return(data.Deserialize());
        }
Пример #18
0
        public async Task GetMatchEvents_InvalidGuid(string guid)
        {
            var query = new GetMatchEvents(Guid.NewGuid())
                        .SkipCache();

            try
            {
                await Global.Session.Query(query);

                Assert.Fail("An exception should have been thrown");
            }
            catch (HaloApiException e)
            {
                Assert.AreEqual((int)Enumeration.Halo5.StatusCode.NotFound, e.HaloApiError.StatusCode);
            }
            catch (System.Exception e)
            {
                Assert.Fail("Unexpected exception of type {0} caught: {1}", e.GetType(), e.Message);
            }
        }
Пример #19
0
        public async Task GetMatchEvents_ModelMatchesSchema(string guid)
        {
            var schema = JSchema.Parse(File.ReadAllText(Config.MatchEventsModelJsonSchemaPath), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri = new Uri(Path.GetFullPath(Config.MatchEventsModelJsonSchemaPath))
            });

            var query = new GetMatchEvents()
                .ForMatchId(new Guid(guid))
                .SkipCache();

            var result = await Global.Session.Query(query);

            var json = JsonConvert.SerializeObject(result);
            var jContainer = JsonConvert.DeserializeObject<JContainer>(json);

            SchemaUtility.AssertSchemaIsValid(schema, jContainer);
        }
Пример #20
0
        public async Task GetMatchEvents_InvalidGuid(string guid)
        {
            var query = new GetMatchEvents()
                .ForMatchId(new Guid(guid))
                .SkipCache();

            try
            {
                await Global.Session.Query(query);
                Assert.Fail("An exception should have been thrown");
            }
            catch (HaloApiException e)
            {
                Assert.AreEqual((int)Enumeration.StatusCode.NotFound, e.HaloApiError.StatusCode);
            }
            catch (System.Exception e)
            {
                Assert.Fail("Unexpected exception of type {0} caught: {1}", e.GetType(), e.Message);
            }
        }
Пример #21
0
        public async Task GetMatchEvents_MissingGuid()
        {
            var query = new GetMatchEvents();

            await Global.Session.Query(query);
            Assert.Fail("An exception should have been thrown");
        }
Пример #22
0
        public async Task GetMatchEvents_SchemaIsValid(string guid)
        {
            var weaponsSchema = JSchema.Parse(File.ReadAllText(Config.MatchEventsJsonSchemaPath), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri = new Uri(Path.GetFullPath(Config.MatchEventsJsonSchemaPath))
            });

            var query = new GetMatchEvents()
                .ForMatchId(new Guid(guid))
                .SkipCache();

            var jArray = await Global.Session.Get<JObject>(query.GetConstructedUri());

            SchemaUtility.AssertSchemaIsValid(weaponsSchema, jArray);
        }
Пример #23
0
        public void Uri_MatchesExpected(string guid)
        {
            var query = new GetMatchEvents(new Guid(guid));

            Assert.AreEqual($"https://www.haloapi.com/stats/h5/matches/{guid}/events", query.Uri);
        }
Пример #24
0
        public async Task GetMatchEvents_IsSerializable(string guid)
        {
            var query = new GetMatchEvents()
                .ForMatchId(new Guid(guid))
                .SkipCache();

            var result = await Global.Session.Query(query);

            SerializationUtility<MatchEvents>.AssertRoundTripSerializationIsPossible(result);
        }