public void GetConstructedUri_NoParameters_MatchesExpected() { var query = new GetWarzoneMatchDetails(); var uri = query.GetConstructedUri(); Assert.AreEqual("stats/h5/warzone/matches/", uri); }
public void GetConstructedUri_NoParamaters_MatchesExpected() { var query = new GetWarzoneMatchDetails(); var uri = query.GetConstructedUri(); Assert.AreEqual(BaseUri, uri); }
public void GetConstructedUri_ForMatchId_MatchesExpected(string guid) { var query = new GetWarzoneMatchDetails() .ForMatchId(new Guid(guid)); var uri = query.GetConstructedUri(); Assert.AreEqual($"stats/h5/warzone/matches/{guid}", uri); }
public async Task GetWarzoneMatchDetails_DoesNotThrow(string guid) { var query = new GetWarzoneMatchDetails() .ForMatchId(new Guid(guid)); var result = await Global.Session.Query(query); Assert.IsInstanceOf(typeof(WarzoneMatch), result); }
public async Task Query_DoesNotThrow() { var query = new GetWarzoneMatchDetails(); var result = await _mockSession.Query(query); Assert.IsInstanceOf(typeof(WarzoneMatch), result); Assert.AreEqual(_warzoneMatch, result); }
public async Task GetWarzoneMatchDetails_IsSerializable(string guid) { var query = new GetWarzoneMatchDetails() .ForMatchId(new Guid(guid)); var result = await Global.Session.Query(query); var serializationUtility = new SerializationUtility<WarzoneMatch>(); serializationUtility.AssertRoundTripSerializationIsPossible(result); }
public async Task GetWarzoneMatchDetails_MissingGuid() { var query = new GetWarzoneMatchDetails(); try { await 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 GetWarzoneMatchDetails(string gamertag) { var getMatchesQuery = new GetMatches() .InGameMode(Enumeration.GameMode.Warzone) .ForPlayer(gamertag); var matches = await Session.Query(getMatchesQuery); Assert.IsTrue(matches.Results.Any()); foreach (var match in matches.Results) { var getWarzoneMatchDetailsQuery = new GetWarzoneMatchDetails() .ForMatchId(match.Id.MatchId); var result = await Session.Query(getWarzoneMatchDetailsQuery); Assert.IsInstanceOf(typeof(WarzoneMatch), result); } }
public async Task GetWarzoneMatchDetails_InvalidGuid(string guid) { var query = new GetWarzoneMatchDetails() .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 GetWarzoneMatchDetails_SchemaIsValid(string guid) { var weaponsSchema = JSchema.Parse(File.ReadAllText(Config.WarzoneMatchJsonSchemaPath), new JSchemaReaderSettings { Resolver = new JSchemaUrlResolver(), BaseUri = new Uri(Path.GetFullPath(Config.WarzoneMatchJsonSchemaPath)) }); var query = new GetWarzoneMatchDetails() .ForMatchId(new Guid(guid)) .SkipCache(); var jArray = await Global.Session.Get<JObject>(query.GetConstructedUri()); SchemaUtility.AssertSchemaIsValid(weaponsSchema, jArray); }
public async Task GetWarzoneMatchDetails_MissingGuid() { var query = new GetWarzoneMatchDetails(); await Global.Session.Query(query); Assert.Fail("An exception should have been thrown"); }
public async Task GetWarzoneMatchDetails_InvalidGuid(string guid) { var query = new GetWarzoneMatchDetails() .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 GetWarzoneMatchDetails_ModelMatchesSchema(string guid) { var schema = JSchema.Parse(File.ReadAllText(Config.WarzoneMatchJsonSchemaPath), new JSchemaReaderSettings { Resolver = new JSchemaUrlResolver(), BaseUri = new Uri(Path.GetFullPath(Config.WarzoneMatchJsonSchemaPath)) }); var query = new GetWarzoneMatchDetails() .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 void Uri_MatchesExpected(string guid) { var query = new GetWarzoneMatchDetails(new Guid(guid)); Assert.AreEqual($"https://www.haloapi.com/stats/h5/warzone/matches/{guid}", query.Uri); }