Пример #1
0
        public void Arrange_should_arrange_inner_component(string contentAlignment, string clipMargin, string expectedInnerLayout, string expectedViewRegion)
        {
            var viewport = new Viewport
            {
                Width            = 30,
                Height           = 30,
                ClipMargin       = Spacer.Parse(clipMargin),
                Inner            = new FixedMeasureComponent(100, 200),
                ContentAlignment = Alignment.Parse(contentAlignment)
            };

            viewport.Measure(new Size(int.MaxValue, int.MaxValue), TestRendererContext.Instance);

            viewport.Arrange(new Rectangle(1, 2, 30, 30));
            viewport.Inner.Layout.ShouldBe(RectParser.ToRect(expectedInnerLayout));
            viewport.ActualViewRegion.ShouldBe(RectParser.ToRect(expectedViewRegion));
        }
Пример #2
0
        public void Arrange_should_arrange_image_accordingly_to_scaling_and_aligning_options(string scaling, string image, string area, string alignment, string expectedSourceRegion, string expectedImageLayout)
        {
            var imgSize  = RectParser.ToSize(image);
            var areaRect = RectParser.ToRect(area);
            var img      = new Image
            {
                Src       = new Bitmap(imgSize.Width, imgSize.Height).ToAssetSource(),
                Scaling   = Enum.Parse <ImageScaling>(scaling, true),
                Alignment = Alignment.Parse(alignment),
                Width     = SizeUnit.Unlimited,
                Height    = SizeUnit.Unlimited
            };

            img.Measure(areaRect.Size, TestRendererContext.Instance);
            img.Arrange(areaRect);

            img.ImageSourceRegion.ShouldBe(RectParser.ToRectF(expectedSourceRegion));
            img.ImageLayout.ShouldBe(RectParser.ToRectF(expectedImageLayout));
        }