Beispiel #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);
        }
Beispiel #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"));
        }
Beispiel #3
0
 public void EnsurePicture_NoApplication()
 {
     TestHelpers.HandleInvocationException(() =>
     {
         SvgView view = new SvgView {
             ResourceId = "DoesNotExist"
         };
         view.CallPrivateMethod("EnsurePicture");
     }, typeof(InvalidOperationException));
 }
Beispiel #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");
        }
Beispiel #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"));
        }
Beispiel #6
0
 public void EnsurePicture_NotFound()
 {
     TestHelpers.HandleInvocationException(() =>
     {
         SvgView.MainPclAssembly = typeof(EnsurePictureTests).Assembly;
         SvgView view            = new SvgView {
             ResourceId = "DoesNotExist"
         };
         view.CallPrivateMethod("EnsurePicture");
     }, typeof(FileNotFoundException));
 }
Beispiel #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);
        }
Beispiel #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));
 }
        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);
        }