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_IsEmpty() { SubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>()); INodeSubGrid subgrid = new NodeSubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels - 1); Assert.True(subgrid.IsEmpty(), "Node subgrid not empty after creation"); Assert.Equal(0, subgrid.CountChildren()); }
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"); }
public void Test_NodeSubGrid_CellHsValue() { 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.True(parentSubgrid.CellHasValue(0, 0), "Cell at 0, 0 does not indicate it has a value"); Assert.False(parentSubgrid.CellHasValue(0, 1), "Cell at 0, 1 does indicate it has a value"); }
public void Test_NodeSubGrid_CountChildren() { 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(parentSubgrid.IsEmpty(), "Parent node subgrid is empty after adding subgrids to parent"); Assert.Equal(0, parentSubgrid.CountChildren()); parentSubgrid.SetSubGrid(0, 0, subgrid); Assert.Equal(1, parentSubgrid.CountChildren()); }
public void Test_NodeSubGrid_SetSubgrid() { SubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>()); INodeSubGrid parentSubgrid = new NodeSubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels - 2); // Fill the entirety of the parent subgrid with new child subgrids using SetSubGrid 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"); Assert.Equal((int)parentSubgrid.CountChildren(), SubGridTreeConsts.CellsPerSubGrid); }
public void Test_NodeSubGrid_DeleteSubGrid() { SubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>()); INodeSubGrid parentSubgrid = new NodeSubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels - 2); // Fill the entirety of the parent subgrid with new child subgrids using SetSubGrid 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)); } // Iterate over all subgrids deleting them one at a time for (int i = 0; i < SubGridTreeConsts.CellsPerSubGrid; i++) { parentSubgrid.DeleteSubGrid((byte)(i / SubGridTreeConsts.SubGridTreeDimension), (byte)(i % SubGridTreeConsts.SubGridTreeDimension)); } Assert.Equal(0, parentSubgrid.CountChildren()); Assert.True(parentSubgrid.IsEmpty(), "Parent not empty after deletion of subgrids"); }