public void Relation_Inheritance_WriteTo() { var relation = new Relation(Car, Vehicle, RelationType.Inheritance); var relationWriter = new RelationWriter(new DiagramContentMixin()); var result = relation.WriteTo(relationWriter); var umlText = result.Finish().ToString(); Assert.AreEqual("[Car]-^[Vehicle]", umlText); }
public void Relation_Composition_WriteTo() { var relation = new Relation(Car, Wheel, RelationType.Composition, "has", 4.ToString()); var relationWriter = new RelationWriter(new DiagramContentMixin()); var result = relation.WriteTo(relationWriter); var umlText = result.Finish().ToString(); Assert.AreEqual("[Car]has++-4[Wheel]", umlText); }
public RelationWriter WriteTo(RelationWriter relationWriter) { Requires(relationWriter != null); var startNode = Start.WriteTo(relationWriter); EndNodeWriter relationEnd; // normally in UML, we could have an association and a navigation, // but Yuml.me only supports one or the other, so we have to check that here if (Start.IsNavigatable) relationEnd = End.WriteTo(startNode.WithNavigation()); else { switch (Type) { case RelationType.Aggregation: relationEnd = End.WriteTo(startNode.AsAggregateOwner()); break; case RelationType.Composition: relationEnd = End.WriteTo(startNode.AsCompositeOwner()); break; case RelationType.Implementation: // start node is the implementation and // end node is the interface relationEnd = startNode .AsSimpleAssociation() .AsInterface(End.Classifier.Name); break; case RelationType.Inheritance: // start node is sub class, // end node is base class relationEnd = startNode .AsSimpleAssociation() .AsBaseClass(End.Classifier.Name); break; case RelationType.Uses: relationEnd = End.WriteTo( startNode .AsUsesRelation() .WithNavigation()); // dependencies are often drawn as navigatable, so we reflect this here also break; case RelationType.Association: default: // default case is a normal association relationEnd = End.WriteTo(startNode.AsSimpleAssociation()); break; } } return relationEnd.Finish(); }