public void GetSizeOfTest() { string str1 = "Jaako Dugacko"; string str2 = "Dugacko"; var n1 = new CustomTreeNode(new SomeCustomClass(str1)); var n2 = new CustomTreeNode(new SomeCustomClass(str2)); var root = new CustomTreeNode(new SomeCustomClass("11"), new List <CustomTreeNode>() { n1, n2 }); root.Init(); var sett = new CustomTreeDrawerSettings(); sett.CanvasPaddingX = sett.CanvasPaddingY = 0; sett.SegmentHeight = sett.SegmentWidth = 5; sett.NodeSize = 2; ICustomTreeDrawer customTypeDrawer = Substitute.For <ICustomTreeDrawer>(); customTypeDrawer.GetSizeOf(Arg.Any <CustomTreeNode>(), Arg.Any <double>(), Arg.Any <bool>()).Returns(a => { var node = (CustomTreeNode)a[0]; var size = (double)a[1]; return(size + 5 * ((SomeCustomClass)node.Info).Title.Length); }); ICustomTreeType type = new NewLineCustomTreeType(sett, customTypeDrawer); //x = settings.CanvasPaddingX + settings.SegmentWidth * node.LeftPadding + settings.NodeSize / 2.0f; ((SomeCustomClass)n1.Info).Title = str1; var mxSize = CustomTreeHelper.DetermineSize(root, type, customTypeDrawer, sett.NodeSize); Assert.AreEqual(str1.Length * 5 + 2 + 5 * 0 + 1 - 1, mxSize); ((SomeCustomClass)n1.Info).Title = str2; root.Init(); mxSize = CustomTreeHelper.DetermineSize(root, type, customTypeDrawer, sett.NodeSize); Assert.AreEqual(str2.Length * 5 + 2 + 5 * 1 + 1 - 1, mxSize); }
public void FixtureSetUp() { CustomTreeNode node71 = new CustomTreeNode(new SomeCustomClass("71")); CustomTreeNode node61 = new CustomTreeNode(new SomeCustomClass("61"), new List <CustomTreeNode>() { node71 }); CustomTreeNode node51 = new CustomTreeNode(new SomeCustomClass("51")); CustomTreeNode node52 = new CustomTreeNode(new SomeCustomClass("52")); CustomTreeNode node53 = new CustomTreeNode(new SomeCustomClass("53"), new List <CustomTreeNode>() { node61 }); CustomTreeNode node14 = new CustomTreeNode(new SomeCustomClass("14"), new List <CustomTreeNode>() { node51, node52 }); CustomTreeNode node24 = new CustomTreeNode(new SomeCustomClass("24"), new List <CustomTreeNode>() { node53 }); CustomTreeNode node13 = new CustomTreeNode(new SomeCustomClass("13")); CustomTreeNode node23 = new CustomTreeNode(new SomeCustomClass("23")); CustomTreeNode node33 = new CustomTreeNode(new SomeCustomClass("33")); node43 = new CustomTreeNode(new SomeCustomClass("Vratice se NODE"), new List <CustomTreeNode>() { node14, node24 }); CustomTreeNode node12 = new CustomTreeNode(new SomeCustomClass("12"), new List <CustomTreeNode>() { node13, node23 }); CustomTreeNode node22 = new CustomTreeNode(new SomeCustomClass("22"), new List <CustomTreeNode>() { node33, node43 }); node32 = new CustomTreeNode(new SomeCustomClass("Coban je nas boban")); complexRoot = new CustomTreeNode(new SomeCustomClass("11"), new List <CustomTreeNode>() { node12, node22, node32 }); complexRoot.Init(); // must initialize everything @see PropertiesShouldFailBeforeInitTest }