コード例 #1
0
        public virtual void NoneModeContainerIsLessThanImageTest()
        {
            ObjectFitApplyingResult result = ObjectFitCalculator.CalculateRenderedImageSize(ObjectFit.NONE, BIG_WIDTH,
                                                                                            BIG_HEIGHT, SMALL_WIDTH, SMALL_HEIGHT);

            NUnit.Framework.Assert.AreEqual(BIG_WIDTH, result.GetRenderedImageWidth(), 0.1);
            NUnit.Framework.Assert.AreEqual(BIG_HEIGHT, result.GetRenderedImageHeight(), 0.1);
            NUnit.Framework.Assert.IsTrue(result.IsImageCuttingRequired());
        }
コード例 #2
0
        public virtual void FillModeContainerIsVerticalAndImageIsHorizontalTest()
        {
            ObjectFitApplyingResult result = ObjectFitCalculator.CalculateRenderedImageSize(ObjectFit.FILL, SMALL_WIDTH
                                                                                            , BIG_HEIGHT, BIG_WIDTH, SMALL_HEIGHT);

            NUnit.Framework.Assert.AreEqual(BIG_WIDTH, result.GetRenderedImageWidth(), 0.1);
            NUnit.Framework.Assert.AreEqual(SMALL_HEIGHT, result.GetRenderedImageHeight(), 0.1);
            NUnit.Framework.Assert.IsFalse(result.IsImageCuttingRequired());
        }
コード例 #3
0
        public virtual void ScaleDownModeContainerIsGreaterThanImageTest()
        {
            ObjectFitApplyingResult result = ObjectFitCalculator.CalculateRenderedImageSize(ObjectFit.SCALE_DOWN, SMALL_WIDTH
                                                                                            , SMALL_HEIGHT, BIG_WIDTH, BIG_HEIGHT);

            NUnit.Framework.Assert.AreEqual(SMALL_WIDTH, result.GetRenderedImageWidth(), 0.1);
            NUnit.Framework.Assert.AreEqual(SMALL_HEIGHT, result.GetRenderedImageHeight(), 0.1);
            NUnit.Framework.Assert.IsFalse(result.IsImageCuttingRequired());
        }
コード例 #4
0
        public virtual void ScaleDownModeContainerIsVerticalAndImageIsHorizontalTest()
        {
            ObjectFitApplyingResult result = ObjectFitCalculator.CalculateRenderedImageSize(ObjectFit.SCALE_DOWN, SMALL_WIDTH
                                                                                            , BIG_HEIGHT, BIG_WIDTH, SMALL_HEIGHT);
            float expectedWidth = SMALL_WIDTH / BIG_HEIGHT * SMALL_HEIGHT;

            NUnit.Framework.Assert.AreEqual(expectedWidth, result.GetRenderedImageWidth(), 0.1);
            NUnit.Framework.Assert.AreEqual(SMALL_HEIGHT, result.GetRenderedImageHeight(), 0.1);
            NUnit.Framework.Assert.IsFalse(result.IsImageCuttingRequired());
        }
コード例 #5
0
        public virtual void CoverModeContainerIsVerticalAndImageIsHorizontalTest()
        {
            ObjectFitApplyingResult result = ObjectFitCalculator.CalculateRenderedImageSize(ObjectFit.COVER, SMALL_WIDTH
                                                                                            , BIG_HEIGHT, BIG_WIDTH, SMALL_HEIGHT);
            float expectedHeight = BIG_HEIGHT / SMALL_WIDTH * BIG_WIDTH;

            NUnit.Framework.Assert.AreEqual(BIG_WIDTH, result.GetRenderedImageWidth(), 0.1);
            NUnit.Framework.Assert.AreEqual(expectedHeight, result.GetRenderedImageHeight(), 0.1);
            NUnit.Framework.Assert.IsTrue(result.IsImageCuttingRequired());
        }
コード例 #6
0
        public virtual void CoverModeContainerIsLessThanImageTest()
        {
            ObjectFitApplyingResult result = ObjectFitCalculator.CalculateRenderedImageSize(ObjectFit.COVER, BIG_WIDTH
                                                                                            , BIG_HEIGHT, SMALL_WIDTH, SMALL_HEIGHT);
            float expectedWidth = BIG_WIDTH / BIG_HEIGHT * SMALL_HEIGHT;

            NUnit.Framework.Assert.AreEqual(expectedWidth, result.GetRenderedImageWidth(), 0.1);
            NUnit.Framework.Assert.AreEqual(SMALL_HEIGHT, result.GetRenderedImageHeight(), 0.1);
            NUnit.Framework.Assert.IsTrue(result.IsImageCuttingRequired());
        }
コード例 #7
0
        public virtual void ContainModeContainerIsGreaterThanImageTest()
        {
            ObjectFitApplyingResult result = ObjectFitCalculator.CalculateRenderedImageSize(ObjectFit.CONTAIN, SMALL_WIDTH
                                                                                            , SMALL_HEIGHT, BIG_WIDTH, BIG_HEIGHT);
            float expectedWidth = SMALL_WIDTH / SMALL_HEIGHT * BIG_HEIGHT;

            NUnit.Framework.Assert.AreEqual(expectedWidth, result.GetRenderedImageWidth(), 0.1);
            NUnit.Framework.Assert.AreEqual(BIG_HEIGHT, result.GetRenderedImageHeight(), 0.1);
            NUnit.Framework.Assert.IsFalse(result.IsImageCuttingRequired());
        }