public void Test_SubGrid_SetOriginPosition_FailWithNoParent() { var leafSubgrid = new SubGrid(null, null, SubGridTreeConsts.SubGridTreeLevels); Action act = () => leafSubgrid.SetOriginPosition(10, 10); act.Should().Throw <ArgumentException>().WithMessage("Cannot set origin position without parent"); }
public void Test_SubGrid_SetOriginPosition_FailWithInvalidCellCoordinateInSubgrid() { ISubGrid parentSubgrid = null; ISubGrid leafSubgrid = null; SubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>()); leafSubgrid = new SubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels); parentSubgrid = new SubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels - 1); leafSubgrid.Parent = parentSubgrid; leafSubgrid.SetOriginPosition(10, 10); Action act = () => leafSubgrid.SetOriginPosition(SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension); act.Should().Throw <ArgumentException>().WithMessage("Cell X, Y location is not in the valid cell address range for the sub grid"); }
public void Test_SubGrid_ParentAssignment() { ISubGrid parentSubgrid = null; ISubGrid leafSubgrid = null; SubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>()); leafSubgrid = new SubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels); parentSubgrid = new SubGrid(tree, null, SubGridTreeConsts.SubGridTreeLevels - 1); leafSubgrid.Parent = parentSubgrid; leafSubgrid.SetOriginPosition(10, 10); Assert.Equal((int)leafSubgrid.OriginX, 10 * SubGridTreeConsts.SubGridTreeDimension); Assert.Equal((int)leafSubgrid.OriginY, 10 * SubGridTreeConsts.SubGridTreeDimension); Assert.Equal(leafSubgrid.Moniker(), string.Format("{0}:{0}", 10 * SubGridTreeConsts.SubGridTreeDimension)); }