Exemplo n.º 1
0
        public string Execute(string[] parameters)
        {
            if (parameters.Any() == false)
            {
                throw new ArgumentOutOfRangeException();
            }

            var giphy = new GiphyService();
            var search = string.Join(" ", parameters);

            var result = giphy.GetGiphyRandom(search);

            // Build the image tag
            using (var sw = new StringWriter())
            {
                using (var htmlWriter = new HtmlTextWriter(sw))
                {
                    htmlWriter.AddAttribute(HtmlTextWriterAttribute.Src, result);
                    htmlWriter.AddAttribute(HtmlTextWriterAttribute.Alt, search);
                    htmlWriter.RenderBeginTag(HtmlTextWriterTag.Img);
                    htmlWriter.RenderEndTag();

                    return sw.ToString();
                }
            }
        }
        public void GetGiphyRandom_Kangaroo()
        {
            var giphy = new GiphyService();
            var imageUrl = giphy.GetGiphyRandom("kangaroo");

            Console.WriteLine($"The image url returned was: {imageUrl}");

            Assert.IsNotNull(imageUrl);
            Assert.IsNotEmpty(imageUrl);
        }