예제 #1
0
        private void TestGetTranslation(float canvasDimension, float svgDimension, SvgAlignment alignment, float expected)
        {
            SvgView svgView = new SvgView();
            float   result  = svgView.CallPrivateMethod <float>("GetTranslation", canvasDimension, svgDimension, alignment);

            Assert.AreEqual(expected, result);
        }
예제 #2
0
        public void EnsurePicture_AlreadyResolved()
        {
            SvgView view  = new SvgView();
            SKSvg   skSvg = new SKSvg();

            view.SetMemberValue("_skSvg", skSvg);
            view.CallPrivateMethod("EnsurePicture");
            Assert.AreEqual(skSvg, view.GetMemberValue <SKSvg>("_skSvg"));
        }
예제 #3
0
 public void EnsurePicture_NoApplication()
 {
     TestHelpers.HandleInvocationException(() =>
     {
         SvgView view = new SvgView {
             ResourceId = "DoesNotExist"
         };
         view.CallPrivateMethod("EnsurePicture");
     }, typeof(InvalidOperationException));
 }
예제 #4
0
        public void EnsurePicture_PrefixResolve()
        {
            SvgView.ResourceIdsPrefix = "XamaRed.Forms.Svg.Tests.Assets.";
            SvgView.MainPclAssembly   = typeof(EnsurePictureTests).Assembly;
            SvgView view = new SvgView {
                ResourceId = "inkscape.svg"
            };

            view.CallPrivateMethod("EnsurePicture");
        }
예제 #5
0
        public void EnsurePicture_Simple()
        {
            SvgView.MainPclAssembly = typeof(EnsurePictureTests).Assembly;
            SvgView view = new SvgView {
                ResourceId = "XamaRed.Forms.Svg.Tests.Assets.inkscape.svg"
            };

            view.CallPrivateMethod("EnsurePicture");
            Assert.IsNotNull(view.GetMemberValue <SKSvg>("_skSvg"));
            Assert.IsNotNull(view.GetMemberValue <SKRect>("_svgRect"));
        }
예제 #6
0
 public void EnsurePicture_NotFound()
 {
     TestHelpers.HandleInvocationException(() =>
     {
         SvgView.MainPclAssembly = typeof(EnsurePictureTests).Assembly;
         SvgView view            = new SvgView {
             ResourceId = "DoesNotExist"
         };
         view.CallPrivateMethod("EnsurePicture");
     }, typeof(FileNotFoundException));
 }
예제 #7
0
        public void EnsurePicture_CacheAdd()
        {
            SvgView.MainPclAssembly = typeof(EnsurePictureTests).Assembly;
            SvgView view = new SvgView {
                ResourceId = "XamaRed.Forms.Svg.Tests.Assets.inkscape.svg"
            };

            view.CallPrivateMethod("EnsurePicture");
            IDictionary <string, SKSvg> cache = typeof(SvgView).GetStaticMemberValue <IDictionary <string, SKSvg> >("SvgCache");

            Assert.AreEqual(1, cache.Count);
        }
예제 #8
0
 public void EnsurePicture_PrefixAbsolute()
 {
     TestHelpers.HandleInvocationException(() =>
     {
         SvgView.ResourceIdsPrefix = "XamaRed.Forms.Svg.Tests.Assets.";
         SvgView.MainPclAssembly   = typeof(EnsurePictureTests).Assembly;
         SvgView view = new SvgView {
             ResourceId = "XamaRed.Forms.Svg.Tests.Assets.inkscape.svg"
         };
         view.CallPrivateMethod("EnsurePicture");
     }, typeof(FileNotFoundException));
 }
예제 #9
0
        private void TestGetScale(SvgStretch stretch, int canvasWidth, int canvasHeight, float svgWidth, float svgHeight, float expectedScaleX, float expectedScaleY)
        {
            SvgView svgView = new SvgView {
                Stretch = stretch
            };

            svgView.SetMemberValue("_svgRect", new SKRect(0, 0, svgWidth, svgHeight));
            SKImageInfo canvasInfo = new SKImageInfo(canvasWidth, canvasHeight);
            SKMatrix    result     = svgView.CallPrivateMethod <SKMatrix>("GetScaleMatrix", canvasInfo);

            Assert.AreEqual(expectedScaleX, result.ScaleX);
            Assert.AreEqual(expectedScaleY, result.ScaleY);
        }