コード例 #1
0
        public void TestSplitRectRandomList()
        {
            // Use the Assert class to test condition
            var testRect = new Rect(0, 0, 10, 10);
            var results  = PuzzleSplitter.SplitRect(testRect, 2, 10);

            Assert.Greater(results.Count, 5);
            var totalMagnitude = results.Sum(x => x.size.volume());

            Assert.AreEqual(testRect.size.volume(), totalMagnitude);
        }
コード例 #2
0
        public void TestSplitRectRandom()
        {
            // Use the Assert class to test condition
            var testRect = new Rect(0, 0, 10, 10);
            var results  = PuzzleSplitter.SplitRect(testRect, 3);

            Assert.True(results.HasValue);
            Assert.Greater(results.Value.Item1.size.magnitude, 9);
            Assert.Greater(results.Value.Item2.size.magnitude, 9);
            var ActualMagnitude = results.Value.Item1.size.volume() + results.Value.Item2.size.volume();

            Assert.AreEqual(testRect.size.volume(), ActualMagnitude);
        }
コード例 #3
0
        public void TestBasicRectSplitVertical()
        {
            // Use the Assert class to test condition
            var testRect = new Rect(0, 0, 10, 10);
            var results  = PuzzleSplitter.SplitRect(testRect, RectTransform.Axis.Vertical, 5);

            Assert.AreEqual(5, results.Item1.width);
            Assert.AreEqual(5, results.Item2.width);
            Assert.AreEqual(5, results.Item2.x);
            var ActualMagnitude = results.Item1.size.volume() + results.Item2.size.volume();

            Assert.AreEqual(testRect.size.volume(), ActualMagnitude);
        }
コード例 #4
0
        public void TestBasicRectSplitHorizontal()
        {
            // Use the Assert class to test condition
            var testRect = new Rect(0, 0, 10, 10);
            var results  = PuzzleSplitter.SplitRect(testRect, RectTransform.Axis.Horizontal, 5);

            Assert.AreEqual(results.Item1.height, 5);
            Assert.AreEqual(results.Item2.height, 5);
            Assert.AreEqual(results.Item2.x, 0);
            Assert.AreEqual(results.Item2.y, 5);
            var ActualMagnitude = results.Item1.size.volume() + results.Item2.size.volume();

            Assert.AreEqual(testRect.size.volume(), ActualMagnitude);
        }