示例#1
0
        public void FitWidthAroundBoundsTest()
        {
            // Create a basic 1000x1000 square.
            Point size = new Point(1000, 1000);

            // Create a parent that is wider than the main size.
            Point wideParent = new Point(1500, 1000);

            // Fit the size into the parent size.
            Assert.IsTrue(AspectRatioHelpers.FitInBounds(ref size, wideParent, ratio, 2f), "Could not fit into parent bounds.");

            // Ensure the size is correct.
            Assert.AreEqual(wideParent.X, size.X, "Adjusted width was incorrect.");
            Assert.AreEqual(844, size.Y, "Adjusted height was incorrect.");
        }
示例#2
0
        public void FitHeightInBoundsTest()
        {
            // Create a basic 1000x1000 square.
            Point size = new Point(1000, 1000);

            // Create a parent that is not as tall as the main size.
            Point shortParent = new Point(1000, 500);

            // Fit the size into the parent size.
            Assert.IsTrue(AspectRatioHelpers.FitInBounds(ref size, shortParent, ratio, 2f), "Could not fit into parent bounds.");

            // Ensure the size is correct.
            Assert.AreEqual(889, size.X, "Adjusted width was incorrect.");
            Assert.AreEqual(shortParent.Y, size.Y, "Adjusted height was incorrect.");
        }