Пример #1
0
        public void ScaleTest2()
        {
            var source = new MediaSource("1045645", 200, 200);

            var rendition = new MediaRenditionInfo(
                host: "google.com",
                source: source,
                transformPath: "100x100/crop(0,0,85,20).png",
                width: 85,
                height: 20
                );

            var b = rendition.Scale(2f);

            Assert.Equal("1045645", b.SourcePath);
            Assert.Equal("crop(0,0,170,40)/170x40.png", b.TransformPath);

            var c = b.Scale(2f);

            Assert.Equal("1045645", c.SourcePath);
            Assert.Equal("crop(0,0,170,40)/340x80.png", c.TransformPath);

            var d = c.WithFormat("gif");

            Assert.Equal("1045645", d.SourcePath);
            Assert.Equal("crop(0,0,170,40)/340x80.gif", d.TransformPath);

            Assert.Equal(340, d.Width);
            Assert.Equal(80, d.Height);
        }
Пример #2
0
        public void WithFormatTests()
        {
            var source = new MediaSource("1045645", 100, 100);

            var a = new MediaRenditionInfo("google.com", source, "100x100/crop(0,0,85,20).png", 85, 20);

            Assert.Equal("https://google.com/1045645;crop(0,0,85,20)/170x40.jpeg", a.Scale(2).WithFormat("jpeg").Url);
        }
Пример #3
0
        public void ScaleTest()
        {
            var source = new MediaSource("1045645", 100, 100);

            var rendition = new MediaRenditionInfo("google.com", source, "100x100/crop(0,0,85,20).png", 85, 20);

            var b = rendition.Scale(2f);

            Assert.Equal("https://google.com/1045645;crop(0,0,85,20)/170x40.png", b.Url);
        }
Пример #4
0
        public void ScaleByFloatingPoint()
        {
            var source = new MediaSource("1045645", 100, 100);

            var rendition = new MediaRenditionInfo(host: null, source, "100x100/crop(0,0,85,20).png", 85, 20);

            var b = rendition.Scale(2.7f);

            Assert.Equal((int)(85 * 2.7), b.Width);
            Assert.Equal((int)(20 * 2.7), b.Height);

            Assert.Equal("crop(0,0,85,20)/229x54.png", b.TransformPath);
        }
Пример #5
0
        public void F()
        {
            var source = new MediaSource("37117398", 1125, 1500);

            var transformation = MediaTransformation.Parse("page(1)/crop(3,0,809,1056)/92x120/bg(fff).webp", source);

            Assert.Equal("page(1)/crop(3,0,809,1056)/92x120/bg(fff).webp", new MediaRenditionInfo(null, transformation, seperator: '/').TransformPath);

            var rendition = new MediaRenditionInfo(null, transformation, seperator: '/');

            var scaled = rendition.Scale(2);


            Assert.Equal("/37117398/page(1)/crop(3,0,809,1056)/184x240/bg(fff).webp", scaled.ToString());
        }
Пример #6
0
        public void ScaleTest4()
        {
            var source = new MediaSource("1045645", 500, 500);

            var rendition = new MediaRenditionInfo(
                host:  null,
                source: source,
                transformPath: "100x100/crop(0,0,85,20).png",
                width: 85,
                height: 20
                );

            var b = rendition.Scale(2.7f);

            Assert.Equal(229, b.Width);
            Assert.Equal(54, b.Height);

            Assert.Equal("crop(0,0,425,100)/229x54.png", b.TransformPath);
            Assert.Equal("/1045645;crop(0,0,425,100)/229x54.png", b.Url);
        }
Пример #7
0
        public void WithFormatTests()
        {
            MediaRenditionInfo.Host = "google.com";

            var rendition = new MediaRenditionInfo(85, 20, "1045645/100x100/crop:0-0_85x20.png");

            var b = rendition.Scale(2).Resample("abc").WithFormat("jpeg");

            Assert.Equal("https://google.com/1045645/200x200/crop:0-0_170x40/resample(abc).jpeg", b.Url);
        }
Пример #8
0
        public void ScaleTest2()
        {
            MediaRenditionInfo.Host = "google.com";

            var rendition = new MediaRenditionInfo(85, 20, "1045645/100x100/crop:0-0_85x20.png");

            var b = rendition.Scale(2f);

            Assert.Equal("200x200/crop:0-0_170x40.png", b.TransformString);

            var c = b.Scale(2f);

            Assert.Equal("400x400/crop:0-0_340x80.png", c.TransformString);

            var d = c.WithFormat("gif");

            Assert.Equal("400x400/crop:0-0_340x80.gif", d.TransformString);
        }
Пример #9
0
        public void ScaleTest()
        {
            MediaRenditionInfo.Host = "google.com";

            var rendition = new MediaRenditionInfo(85, 20, "1045645/100x100/crop:0-0_85x20.png");

            var b = rendition.Scale(2f);

            Assert.Equal("https://google.com/1045645/200x200/crop:0-0_170x40.png", b.Url);
        }
Пример #10
0
        public void ResampleTest2()
        {
            MediaRenditionInfo.Host = "google.com";

            var rendition = new MediaRenditionInfo(85, 20, "1045645/100x100/crop:0-0_85x20.png");

            var b = rendition.Scale(2).Resample("abc");

            MediaRenditionInfo.Signer = new Signer("hey");

            Assert.Equal("https://google.com/hey/1045645/200x200/crop:0-0_170x40/resample(abc).png", b.Url);

            MediaRenditionInfo.Signer = null;
        }
Пример #11
0
        public void Sign2()
        {
            var signer = new MD5Signer();

            var source = new MediaSource("1045645", 100, 100);

            var rendition = new MediaRenditionInfo("google.com", source, "100x100/crop(0,0,85,20).png", 85, 20, signer: signer);

            Assert.Equal("https://google.com/86a04659943b28fbef72f0bc42254aa0/1045645;100x100/crop(0,0,85,20).png", rendition.Url);
            Assert.Equal("https://google.com/f3a779d1806577fddfe7c211e7deb183/1045645;crop(0,0,85,20)/170x40.png", rendition.Scale(2f).Url);
            Assert.Equal("https://google.com/b9a9185d2e2b0ca878fe2f31df45ad6c/1045645;crop(0,0,85,20)/170x40.jpeg", rendition.Scale(2f).WithFormat("jpeg").Url);
        }
Пример #12
0
        public void Sign1()
        {
            var signer = new Signer("sig");

            var source = new MediaSource("1045645", 1000, 1000);

            var rendition = new MediaRenditionInfo("google.com", source, "crop(0,0,850,200)/170x40.png", 85, 20, signer: signer);

            Assert.Equal("https://google.com/sig/1045645;crop(0,0,850,200)/170x40.png", rendition.Url);
            Assert.Equal("https://google.com/sig/1045645;crop(0,0,850,200)/340x80.png", rendition.Scale(2f).Url);
            Assert.Equal("https://google.com/sig/1045645;crop(0,0,850,200)/340x80.jpeg", rendition.Scale(2f).WithFormat("jpeg").Url);
        }