public void Test_NodeSubGrid_Clear_Single() { SubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>()); INodeSubGrid subgrid = new NodeSubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels - 1); INodeSubGrid parentSubgrid = new NodeSubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels - 2); Assert.True(subgrid.IsEmpty(), "Node subgrid not empty after creation"); Assert.True(parentSubgrid.IsEmpty(), "Parent node subgrid not empty after creation"); parentSubgrid.SetSubGrid(0, 0, subgrid); Assert.False(parentSubgrid.IsEmpty(), "Parent node subgrid is empty after adding subgrid to parent"); parentSubgrid.Clear(); Assert.True(parentSubgrid.IsEmpty(), "Parent node subgrid not empty after calling Clear()"); }
public void Test_NodeSubGrid_Clear_Many() { SubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>()); INodeSubGrid parentSubgrid = new NodeSubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels - 2); Assert.True(parentSubgrid.IsEmpty(), "Parent node subgrid not empty after creation"); // Fill the entirety of the parent subgrid with new child subgrids for (int i = 0; i < SubGridTreeConsts.CellsPerSubGrid; i++) { parentSubgrid.SetSubGrid((byte)(i / SubGridTreeConsts.SubGridTreeDimension), (byte)(i % SubGridTreeConsts.SubGridTreeDimension), new NodeSubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels - 1)); } Assert.False(parentSubgrid.IsEmpty(), "Parent node subgrid is empty after adding subgrids to parent"); parentSubgrid.Clear(); Assert.True(parentSubgrid.IsEmpty(), "Parent node subgrid not empty after calling Clear() to remove all subgrids"); }