Exemplo n.º 1
0
        public async Task GetMatches_InvalidGamertag(string gamertag)
        {
            var query = new GetMatchHistory(gamertag);

            await Global.Session.Query(query);

            Assert.Fail("An exception should have been thrown");
        }
Exemplo n.º 2
0
        public async Task GetMatches_DoesNotThrow(string gamertag)
        {
            var query = new GetMatchHistory(gamertag)
                        .SkipCache();

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

            Assert.IsInstanceOf(typeof(MatchSet <PlayerMatch>), result);
        }
Exemplo n.º 3
0
        public async Task GetMatchHistory_DoesNotThrow(string player)
        {
            var query = new GetMatchHistory(player)
                        .SkipCache();

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

            Assert.IsInstanceOf(typeof(MatchSet <Model.HaloWars2.Stats.PlayerMatch>), result);
        }
Exemplo n.º 4
0
        public async Task GetMatches_IsSerializable(string gamertag)
        {
            var query = new GetMatchHistory(gamertag)
                        .SkipCache();

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

            SerializationUtility <MatchSet <PlayerMatch> > .AssertRoundTripSerializationIsPossible(result);
        }
Exemplo n.º 5
0
        public async Task GetMatchHistory_InvalidGamertag(string player)
        {
            var query = new GetMatchHistory(player)
                        .SkipCache();

            await Global.Session.Query(query);

            Assert.Fail("An exception should have been thrown");
        }
Exemplo n.º 6
0
        public async Task GetMatchHistory_IsSerializable(string player)
        {
            var query = new GetMatchHistory(player)
                        .SkipCache();

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

            SerializationUtility <MatchSet <Model.HaloWars2.Stats.PlayerMatch> > .AssertRoundTripSerializationIsPossible(result);
        }
Exemplo n.º 7
0
        public async Task Query_DoesNotThrow(string gamertag)
        {
            var query = new GetMatchHistory(gamertag)
                        .SkipCache();

            var result = await _mockSession.Query(query);

            Assert.IsInstanceOf(typeof(MatchSet <PlayerMatch>), result);
            Assert.AreEqual(_matchSet, result);
        }
Exemplo n.º 8
0
        public async Task GetMatches_SchemaIsValid(string gamertag)
        {
            var weaponsSchema = JSchema.Parse(File.ReadAllText(Halo5Config.MatchesJsonSchemaPath), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri  = new Uri(Path.GetFullPath(Halo5Config.MatchesJsonSchemaPath))
            });

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

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

            SchemaUtility.AssertSchemaIsValid(weaponsSchema, jArray);
        }
Exemplo n.º 9
0
        public async Task GetMatchHistory_SchemaIsValid(string player)
        {
            var jSchema = JSchema.Parse(File.ReadAllText(Schema), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri  = new Uri(Path.GetFullPath(Schema))
            });

            var query = new GetMatchHistory(player)
                        .SkipCache();

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

            SchemaUtility.AssertSchemaIsValid(jSchema, jArray);
        }
Exemplo n.º 10
0
        public void Uri_MatchesExpected(string gamertag, Enumeration.Halo5.GameMode gameMode, int skip, int take)
        {
            var query = new GetMatchHistory(gamertag);

            Assert.AreEqual($"https://www.haloapi.com/stats/h5/players/{gamertag}/matches", query.Uri);

            query.InGameMode(gameMode);

            Assert.AreEqual($"https://www.haloapi.com/stats/h5/players/{gamertag}/matches?modes={gameMode}", query.Uri);

            query.Skip(skip);

            Assert.AreEqual($"https://www.haloapi.com/stats/h5/players/{gamertag}/matches?modes={gameMode}&start={skip}", query.Uri);

            query.Take(take);

            Assert.AreEqual($"https://www.haloapi.com/stats/h5/players/{gamertag}/matches?modes={gameMode}&start={skip}&count={take}", query.Uri);
        }
Exemplo n.º 11
0
        public async Task GetMatches_ModelMatchesSchema(string gamertag)
        {
            var schema = JSchema.Parse(File.ReadAllText(Halo5Config.MatchesJsonSchemaPath), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri  = new Uri(Path.GetFullPath(Halo5Config.MatchesJsonSchemaPath))
            });

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

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

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

            SchemaUtility.AssertSchemaIsValid(schema, jContainer);
        }
Exemplo n.º 12
0
        public void Uri_MatchesExpected(string player, Enumeration.HaloWars2.MatchType matchType, int skip, int take)
        {
            var query = new GetMatchHistory(player);

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

            query.ForMatchType(matchType);

            Assert.AreEqual($"https://www.haloapi.com/stats/hw2/players/{player}/matches?matchType={matchType}", query.Uri);

            query.Skip(skip);

            Assert.AreEqual($"https://www.haloapi.com/stats/hw2/players/{player}/matches?matchType={matchType}&start={skip}", query.Uri);

            query.Take(take);

            Assert.AreEqual($"https://www.haloapi.com/stats/hw2/players/{player}/matches?matchType={matchType}&start={skip}&count={take}", query.Uri);
        }