TestCollapsedAttributes() { // With vertex names. IVertex oAnchorVertex1 = new Vertex(); IVertex oAnchorVertex2 = new Vertex(); oAnchorVertex1.Name = "Name1"; oAnchorVertex2.Name = "Name2"; DConnectorMotif oDConnectorMotif = new DConnectorMotif( new List <IVertex>() { oAnchorVertex1, oAnchorVertex2 }); IVertex oSpanVertex1 = new Vertex(); IVertex oSpanVertex2 = new Vertex(); oDConnectorMotif.SpanVertices.Add(oSpanVertex1); oDConnectorMotif.SpanVertices.Add(oSpanVertex2); String sCollapsedAttributes = oDConnectorMotif.CollapsedAttributes; CollapsedGroupAttributes oCollapsedGroupAttributes = CollapsedGroupAttributes.FromString(sCollapsedAttributes); Assert.AreEqual(CollapsedGroupAttributeValues.DConnectorMotifType, oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.Type]); Assert.AreEqual("2", oCollapsedGroupAttributes[ CollapsedGroupAttributeKeys.AnchorVertices]); Assert.IsTrue(oCollapsedGroupAttributes.ContainsKey( CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(0))); Assert.IsTrue(oCollapsedGroupAttributes.ContainsKey( CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(1))); Assert.AreEqual("Name1", oCollapsedGroupAttributes[ CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(0)]); Assert.AreEqual("Name2", oCollapsedGroupAttributes[ CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(1)]); Assert.AreEqual("2", oCollapsedGroupAttributes[ CollapsedGroupAttributeKeys.SpanVertices]); Assert.IsTrue(oCollapsedGroupAttributes.ContainsKey( CollapsedGroupAttributeKeys.SpanScale)); Assert.AreEqual("1", oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.SpanScale]); }
TestCollapsedAttributes2() { // Without vertex names and with SpanScale set to a non-default value. IVertex oAnchorVertex1 = new Vertex(); IVertex oAnchorVertex2 = new Vertex(); DConnectorMotif oDConnectorMotif = new DConnectorMotif( new List <IVertex>() { oAnchorVertex1, oAnchorVertex2 }); IVertex oSpanVertex1 = new Vertex(); IVertex oSpanVertex2 = new Vertex(); oDConnectorMotif.SpanVertices.Add(oSpanVertex1); oDConnectorMotif.SpanVertices.Add(oSpanVertex2); oDConnectorMotif.SpanScale = 0.5; String sCollapsedAttributes = oDConnectorMotif.CollapsedAttributes; CollapsedGroupAttributes oCollapsedGroupAttributes = CollapsedGroupAttributes.FromString(sCollapsedAttributes); Assert.AreEqual(CollapsedGroupAttributeValues.DConnectorMotifType, oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.Type]); Assert.AreEqual("2", oCollapsedGroupAttributes[ CollapsedGroupAttributeKeys.AnchorVertices]); Assert.IsFalse(oCollapsedGroupAttributes.ContainsKey( CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(0))); Assert.IsFalse(oCollapsedGroupAttributes.ContainsKey( CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(1))); Assert.AreEqual("2", oCollapsedGroupAttributes[ CollapsedGroupAttributeKeys.SpanVertices]); Assert.IsTrue(oCollapsedGroupAttributes.ContainsKey( CollapsedGroupAttributeKeys.SpanScale)); Assert.AreEqual("0.5", oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.SpanScale]); }
TestCollapsedAttributes() { // With head vertex name. IVertex oHeadVertex = new Vertex(); oHeadVertex.Name = "Head"; IVertex oLeafVertex1 = new Vertex(); IVertex oLeafVertex2 = new Vertex(); FanMotif oFanMotif = new FanMotif(oHeadVertex, new IVertex[] { oLeafVertex1, oLeafVertex2 }); String sCollapsedAttributes = oFanMotif.CollapsedAttributes; CollapsedGroupAttributes oCollapsedGroupAttributes = CollapsedGroupAttributes.FromString(sCollapsedAttributes); Assert.AreEqual(CollapsedGroupAttributeValues.FanMotifType, oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.Type]); Assert.IsTrue( oCollapsedGroupAttributes.ContainsKey( CollapsedGroupAttributeKeys.HeadVertexName)); Assert.AreEqual("Head", oCollapsedGroupAttributes[ CollapsedGroupAttributeKeys.HeadVertexName]); Assert.AreEqual("2", oCollapsedGroupAttributes[ CollapsedGroupAttributeKeys.LeafVertices]); Assert.IsTrue( oCollapsedGroupAttributes.ContainsKey( CollapsedGroupAttributeKeys.ArcScale)); Assert.AreEqual("1", oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.ArcScale]); }
TestToAndFromString2() { // Empty and null keys, which aren't persisted. m_oCollapsedGroupAttributes.Add("Key1", "Value1"); m_oCollapsedGroupAttributes.Add("KeyX", ""); m_oCollapsedGroupAttributes.Add("Key2", "Value2"); m_oCollapsedGroupAttributes.Add("Key3", "Value3"); m_oCollapsedGroupAttributes.Add("KeyY", null); String sSavedString = m_oCollapsedGroupAttributes.ToString(); CollapsedGroupAttributes oCollapsedGroupAttributes2 = CollapsedGroupAttributes.FromString(sSavedString); Assert.AreEqual("Value1", oCollapsedGroupAttributes2["Key1"]); Assert.AreEqual("Value2", oCollapsedGroupAttributes2["Key2"]); Assert.AreEqual("Value3", oCollapsedGroupAttributes2["Key3"]); Assert.IsFalse(oCollapsedGroupAttributes2.ContainsKey("KeyX")); Assert.IsFalse(oCollapsedGroupAttributes2.ContainsKey("KeyY")); }
TestCollapsedAttributes2() { // Without head vertex name, and with ArcScale set to a non-default // value. IVertex oHeadVertex = new Vertex(); IVertex oLeafVertex1 = new Vertex(); IVertex oLeafVertex2 = new Vertex(); FanMotif oFanMotif = new FanMotif(oHeadVertex, new IVertex[] { oLeafVertex1, oLeafVertex2 }); oFanMotif.ArcScale = 0.5; String sCollapsedAttributes = oFanMotif.CollapsedAttributes; CollapsedGroupAttributes oCollapsedGroupAttributes = CollapsedGroupAttributes.FromString(sCollapsedAttributes); Assert.AreEqual(CollapsedGroupAttributeValues.FanMotifType, oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.Type]); Assert.IsFalse( oCollapsedGroupAttributes.ContainsKey( CollapsedGroupAttributeKeys.HeadVertexName)); Assert.AreEqual("2", oCollapsedGroupAttributes[ CollapsedGroupAttributeKeys.LeafVertices]); Assert.IsTrue( oCollapsedGroupAttributes.ContainsKey( CollapsedGroupAttributeKeys.ArcScale)); Assert.AreEqual("0.5", oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.ArcScale]); }