public void Test_LeafSubgrid_IsEmpty() { ISubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>()); ILeafSubGrid leaf = new LeafSubGrid(tree, null, tree.NumLevels); leaf.IsEmpty().Should().BeTrue(); }
public void Test_LeafSubgrid_Creation() { ISubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>()); ILeafSubGrid leaf = null; // Test creation of a leaf node without an owner tree try { leaf = new LeafSubGrid(null, null, (byte)(tree.NumLevels + 1)); Assert.True(false, "Was able to create a leaf subgrid with no owning tree"); } catch (Exception) { // As expected } // Test creation of a leaf node at an inappropriate level try { leaf = new LeafSubGrid(tree, null, (byte)(tree.NumLevels + 1)); Assert.True(false, "Was able to create a leaf subgrid at an inappropriate level"); } catch (Exception) { // As expected } leaf = new LeafSubGrid(tree, null, tree.NumLevels); Assert.True(leaf != null && leaf.Level == tree.NumLevels); }
public void Test_SubGrid_RemoveFromParent() { // This can't be tested fully as the entire Set/Get subgrid functionality is abstract at this point, and // RemoveFromParent is part of that abstract workflow. At this level, we will test that no exception occurs // if the parent relationship is null SubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>()); var parentSubgrid = new NodeSubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels - 1); var leafSubgrid = new LeafSubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels); parentSubgrid.SetSubGrid(0, 0, leafSubgrid); leafSubgrid.RemoveFromParent(); leafSubgrid.Parent.Should().BeNull(); }