public void AssertThat_GenerateBounds_ProducesAlternatelyAlignedRectangle_WithDepth3() { //Create a tree with hand calculated split values var tree = new Node <TestData>(null, null, true, 10) { new Node <TestData>(null, new TestData("0"), false, 4) { new Node <TestData>(null, new TestData("1"), 2), new Node <TestData>(null, new TestData("2"), 8), }, new Node <TestData>(null, new TestData("3"), 6), }; //Generate the boundaries for this tree Treemap <TestData> .GenerateBounds(new BoundingRectangle(new Vector2(0, 0), new Vector2(10, 10)), new [] { tree }, true); DrawTreemap(tree); //Does the root take all the available space? Assert.AreEqual(new BoundingRectangle(new Vector2(0, 0), new Vector2(10, 10)), tree.Bounds); //Do the inner nodes take the correct space? Assert.AreEqual(new BoundingRectangle(new Vector2(0, 0), new Vector2(4, 10)), tree.First().Bounds); Assert.AreEqual(new BoundingRectangle(new Vector2(4, 0), new Vector2(10, 10)), tree.Skip(1).First().Bounds); //Do the leaves take the correct space? Assert.AreEqual(new BoundingRectangle(new Vector2(0, 0), new Vector2(4, 2)), tree.First().First().Bounds); Assert.AreEqual(new BoundingRectangle(new Vector2(0, 2), new Vector2(4, 10)), tree.First().Skip(1).First().Bounds); }
public void AssertThat_GenerateBounds_ProducesSpecifiedRectangles_WithRootNode_WithTwoChildren_WithNonZeroRectangle() { var a = new Node <TestData>(null, new TestData("0"), 4); var b = new Node <TestData>(null, new TestData("1"), 6); Treemap <TestData> .GenerateBounds(new BoundingRectangle(new Vector2(-7, -5), new Vector2(3, 5)), new[] { a, b, }, true); Assert.AreEqual(new BoundingRectangle(new Vector2(-7, -5), new Vector2(-3, 5)), a.Bounds); Assert.AreEqual(new BoundingRectangle(new Vector2(-3, -5), new Vector2(3, 5)), b.Bounds); }