Ejemplo n.º 1
0
        private IEnumerable <string> LastGameHighlights(int team)
        {
            List <string> result   = new List <string>();
            NHLApiClient  api      = new NHLApiClient();
            var           lastGame = api.GetLastGame(team);
            var           gameId   = lastGame.Dates[0].Games[0].GamePk;

            var content = api.GetGameContent(gameId);

            foreach (var highlight in content.Highlights.Scoreboard.Items)
            {
                if (highlight.Type != "video")
                {
                    continue;
                }

                var builder = new StringBuilder();
                var vid     = highlight.Playbacks.Last();
                builder.AppendLine(highlight.Title);
                builder.AppendLine(vid.URL);

                result.Add(builder.ToString());
            }

            return(result);
        }
        private IEnumerable <string> LastGameHighlights(string team)
        {
            Locator.Instance.Fetch <ILogger>().LogLine("Executing LastGameHighlights command for team: " + team);
            List <string> result = new List <string>();
            NHLApiClient  api    = new NHLApiClient();
            int           teamId = -1;

            var isTeamId = int.TryParse(team, out teamId);

            if (!isTeamId)
            {
                var Ids = Locator.Instance.Fetch <TeamNameTranslator>().LookupIdsForName(team);
                if (Ids.Count > 1)
                {
                    result.Add("Name conflict, got more than one team ID for " + team + ". Please be more specific.");
                    return(result);
                }

                if (Ids.Count == 0)
                {
                    result.Add("Couldn't find a team by the name " + team + ". Please try another name.");
                    return(result);
                }

                teamId = Ids.First().Key;
            }

            var lastGame = api.GetLastGame(teamId);
            var gameId   = lastGame.Dates[0].Games[0].GamePk;

            var content = api.GetGameContent(gameId);

            foreach (var highlight in content.Highlights.Scoreboard.Items)
            {
                if (highlight.Type != "video")
                {
                    continue;
                }

                var builder = new StringBuilder();
                var vid     = highlight.Playbacks.Last();
                builder.AppendLine(highlight.Title);
                builder.AppendLine(vid.URL);

                result.Add(builder.ToString());
            }

            return(result);
        }
Ejemplo n.º 3
0
        public void GetGameContentTestBasic()
        {
            NHLApiClient api = new NHLApiClient();

            // Load Expected result from file
            var testResponse = File.ReadAllText(@"../../../TestAPIResponses/GetGameContentResult.json");
            var jobj         = JObject.Parse(testResponse);
            var expected     = JsonConvert.DeserializeObject <GameContent>(jobj.ToString());

            // Make API web call
            GameContent actual = api.GetGameContent(2017030325); //Jets vs Vegas WCF Game 5 2018

            //Assert
            Assert.AreEqual(expected, actual);
        }