public async Task GetCampaignProgress_DoesNotThrow(string gamertag)
        {
            var query = new GetCampaignSummary(gamertag)
                        .SkipCache();

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

            Assert.IsInstanceOf(typeof(CampaignSummary), result);
        }
        public async Task GetCampaignProgress_InvalidGamertag(string gamertag)
        {
            var query = new GetCampaignSummary(gamertag)
                        .SkipCache();

            await Global.Session.Query(query);

            Assert.Fail("An exception should have been thrown");
        }
        public async Task GetCampaignProgress_IsSerializable(string gamertag)
        {
            var query = new GetCampaignSummary(gamertag)
                        .SkipCache();

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

            SerializationUtility <CampaignSummary> .AssertRoundTripSerializationIsPossible(result);
        }
        public async Task Query_DoesNotThrow(string gamertag)
        {
            var query = new GetCampaignSummary(gamertag)
                        .SkipCache();

            var result = await _mockSession.Query(query);

            Assert.IsInstanceOf(typeof(CampaignSummary), result);
            Assert.AreEqual(_response, result);
        }
        public async Task GetCampaignProgress_SchemaIsValid(string gamertag)
        {
            var jSchema = JSchema.Parse(File.ReadAllText(Schema), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri  = new Uri(Path.GetFullPath(Schema))
            });

            var query = new GetCampaignSummary(gamertag)
                        .SkipCache();

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

            SchemaUtility.AssertSchemaIsValid(jSchema, jArray);
        }
        public async Task GetCampaignProgress_ModelMatchesSchema(string gamertag)
        {
            var schema = JSchema.Parse(File.ReadAllText(Schema), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri  = new Uri(Path.GetFullPath(Schema))
            });

            var query = new GetCampaignSummary(gamertag)
                        .SkipCache();

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

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

            SchemaUtility.AssertSchemaIsValid(schema, jContainer);
        }
        public void Uri_MatchesExpected(string player)
        {
            var query = new GetCampaignSummary(player);

            Assert.AreEqual($"https://www.haloapi.com/stats/hw2/players/{player}/campaign-progress", query.Uri);
        }