private void GenerateTestHierarchicalReferenceFile(string path, double width, double height) { // Generate reference hierarchical data with layout info var generator = new HierarchicalDataBuilder(); var root = generator.GenerateRandomHierarchy(); var layout = new CirclePackingLayout(); layout.Layout(root, width, height); var file = new BinaryFile <HierarchicalData>(); file.Write(path, root); }
private static void AssertLayouting(string path, double width, double height) { var layout = new CirclePackingLayout(); var binFile = new BinaryFile <HierarchicalData>(); var data = binFile.Read(path); // Includes layout info var reference = data.Dump(); Assert.IsTrue(File.Exists(path)); var clone = (HierarchicalData)data.Clone(); // Clone does not copy the layout. layout.Layout(clone, width, height); var result = clone.Dump(); Assert.AreEqual(reference, result); }
public void SingleRootNodeWithoutArea() { var data = new HierarchicalData("", 0.0); var layout = new CirclePackingLayout(); // Disable assertions var backup = new TraceListener[Debug.Listeners.Count]; Debug.Listeners.CopyTo(backup, 0); Debug.Listeners.Clear(); layout.Layout(data, 100, 100); // Restore assertions Debug.Listeners.AddRange(backup); Assert.AreEqual("(x-0)^2+(y-0)^2=0^2", data.Layout.ToString()); }