public void GetConstructedUri_NoParameters_MatchesExpected() { var query = new GetMatchEvents(); var uri = query.GetConstructedUri(); Assert.AreEqual("stats/h5/matches//events", uri); }
public async Task GetMatchEvents_MissingGuid() { var query = new GetMatchEvents(); await Global.Session.Query(query); Assert.Fail("An exception should have been thrown"); }
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); }
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); }
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); }
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); }
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); }
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); }
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); } }
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(); }
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); }
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); }
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); }
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()); }
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); } }
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); }
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); } }
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); }
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); }
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); }