Beispiel #1
0
        public void CreateEmbedDataTest_Medias_Other(string type)
        {
            var t = new OEmbedProxyMetadata()
            {
                Url = "http://t"
            };
            var d = t.CreateEmbedData(new Dictionary <string, object>()
            {
                ["type"]             = type,
                ["thumbnail_url"]    = "http://thumb",
                ["thumbnail_width"]  = 48,
                ["thumbnail_height"] = 32,
                ["url"]    = "http://url",
                ["width"]  = 480,
                ["height"] = 320,
            });

            Assert.Equal(EmbedDataTypes.MixedContent, d.Type);
            Assert.Equal("http://thumb", d.MetadataImage.Thumbnail.Url);
            Assert.Equal(48, d.MetadataImage.Thumbnail.Width);
            Assert.Equal(32, d.MetadataImage.Thumbnail.Height);
            Assert.Null(d.MetadataImage.RawUrl);
            Assert.Null(d.MetadataImage.Location);
            Assert.False(d.Medias.Any());
        }
Beispiel #2
0
        public void CreateEmbedDataTest_Medias_Video()
        {
            var t = new OEmbedProxyMetadata()
            {
                Url = "http://t"
            };
            var d = t.CreateEmbedData(new Dictionary <string, object>()
            {
                ["type"]             = "video",
                ["thumbnail_url"]    = "http://thumb",
                ["thumbnail_width"]  = 48,
                ["thumbnail_height"] = 32,
                ["url"]    = "http://url",
                ["width"]  = 480,
                ["height"] = 320,
            });

            Assert.Equal(EmbedDataTypes.SingleVideo, d.Type);
            Assert.Equal("http://thumb", d.MetadataImage.Thumbnail.Url);
            Assert.Equal(48, d.MetadataImage.Thumbnail.Width);
            Assert.Equal(32, d.MetadataImage.Thumbnail.Height);
            Assert.Equal("http://t", d.MetadataImage.RawUrl);
            Assert.Equal("http://t", d.MetadataImage.Location);
            Assert.Equal(d.MetadataImage, d.Medias.Single());
        }
Beispiel #3
0
        public void SerializationTest()
        {
            var url       = "http://www.flickr.com/photos/bees/2341623661/";
            var oEmbedUrl = "http://www.flickr.com/services/oembed/?format=json&url=http%3A//www.flickr.com/photos/bees/2341623661/";

            var rm = new OEmbedProxyMetadata()
            {
                Url       = url,
                OEmbedUrl = oEmbedUrl
            };

            var d1 = rm.FetchAsync(new RequestContext(new MetadataService(), new ConsumerRequest(new Uri(url)))).GetAwaiter().GetResult();

            Assert.Equal(rm.Data, d1);

            using (var sw = new StringWriter())
            {
                XamlServices.Save(sw, rm);

                var xml = sw.ToString();
                using (var sr = new StringReader(xml))
                {
                    var obj = XamlServices.Load(sr);
                    Assert.IsType <OEmbedProxyMetadata>(obj);

                    var rm2 = (OEmbedProxyMetadata)obj;

                    Assert.NotNull(rm2.Data);
                }
            }
        }
Beispiel #4
0
        public void CreateEmbedDataTest_ProviderName()
        {
            var t = new OEmbedProxyMetadata()
            {
                Url = "http://t"
            };
            var value = "hoge hoge";
            var d     = t.CreateEmbedData(new Dictionary <string, object>()
            {
                ["provider_name"] = value
            });

            Assert.Equal(value, d.ProviderName);
        }
Beispiel #5
0
        public void CreateEmbedDataTest_AuthorUrl()
        {
            var t = new OEmbedProxyMetadata()
            {
                Url = "http://t"
            };
            var value = "http://hoge";
            var d     = t.CreateEmbedData(new Dictionary <string, object>()
            {
                ["author_url"] = value
            });

            Assert.Equal(value, d.AuthorUrl);
        }
Beispiel #6
0
        public void CreateEmbedDataTest_CacheAge()
        {
            var t = new OEmbedProxyMetadata()
            {
                Url = "http://t"
            };
            var value = "123";
            var d     = t.CreateEmbedData(new Dictionary <string, object>()
            {
                ["cache_age"] = value
            });

            Assert.Equal(123, d.CacheAge);
        }