Example #1
0
        static void TestPositioner_HFlat1X2(float factor)
        {
            var rc = Positioner.DoPosition(HFlat1X2Pos, R1X1.Grow(factor), new[] { R1X1, R1X1 }).CheapToArray();

            Assert.AreEqual(2, rc.Length);
            var expected = new Rectangle(0, .25f, .5f, .5f).Scale(factor, factor);

            Assert.AreEqual(expected, rc.First());
            expected = expected.MoveBy(.5f * factor, 0);
            Assert.AreEqual(expected, rc.Skip(1).First());
        }
        internal static void Run(Rectangle clientArea, IEnumerable <Rectangle> rectangles, Positioner.Parms pos, IEnumerable <Rectangle> expected, string label)
        {
            var rc = Positioner.DoPosition(pos, clientArea, rectangles).CheapToArray();

            expected = expected.CheapToArray();
            Assert.AreEqual(expected.Count(), rc.Length, $"{label}: Results length");
            var results = expected.EquiZip(rc, (e, r) => new { expected = e, results = r })
                          .Select((r, i) => new { i, r.expected, r.results, success = r.expected.Equals(r.results) })
                          .ToArray();

            Assert.IsTrue(results.All(r => r.success), results.Select(r => $"{Environment.NewLine}{r.expected} {(r.success ? "==" : "<>")} {r.results}").ToDelimitedString(","), $"{label}: equality");
        }