@@ -9,31 +9,32 @@ namespace GitVersion.Testing;
99public class SequenceDiagram
1010{
1111 private readonly Dictionary < string , string > participants = [ ] ;
12- private readonly StringBuilder diagramBuilder ;
1312
1413 /// <summary>
1514 /// Initializes a new instance of the <see cref="T:SequenceDiagram"/> class.
1615 /// </summary>
1716 public SequenceDiagram ( )
1817 {
19- this . diagramBuilder = new StringBuilder ( ) ;
20- this . diagramBuilder . AppendLine ( "@startuml" ) ;
18+ this . DiagramBuilder = new StringBuilder ( ) ;
19+ this . DiagramBuilder . AppendLine ( "@startuml" ) ;
2120 }
2221
22+ public StringBuilder DiagramBuilder { get ; }
23+
2324 /// <summary>
2425 /// Activates a branch/participant in the sequence diagram
2526 /// </summary>
26- public void Activate ( string branch ) => this . diagramBuilder . AppendLineFormat ( "activate {0}" , GetParticipant ( branch ) ) ;
27+ public void Activate ( string branch ) => this . DiagramBuilder . AppendLineFormat ( "activate {0}" , GetParticipant ( branch ) ) ;
2728
2829 /// <summary>
2930 /// Deactivates a branch/participant in the sequence diagram
3031 /// </summary>
31- public void Deactivate ( string branch ) => this . diagramBuilder . AppendLineFormat ( "deactivate {0}" , GetParticipant ( branch ) ) ;
32+ public void Deactivate ( string branch ) => this . DiagramBuilder . AppendLineFormat ( "deactivate {0}" , GetParticipant ( branch ) ) ;
3233
3334 /// <summary>
3435 /// Destroys a branch/participant in the sequence diagram
3536 /// </summary>
36- public void Destroy ( string branch ) => this . diagramBuilder . AppendLineFormat ( "destroy {0}" , GetParticipant ( branch ) ) ;
37+ public void Destroy ( string branch ) => this . DiagramBuilder . AppendLineFormat ( "destroy {0}" , GetParticipant ( branch ) ) ;
3738
3839 /// <summary>
3940 /// Creates a participant in the sequence diagram
@@ -43,21 +44,21 @@ public void Participant(string participant, string? @as = null)
4344 var cleanParticipant = ParticipantSanitizer . SanitizeParticipant ( @as ?? participant ) ;
4445 this . participants . Add ( participant , cleanParticipant ) ;
4546 if ( participant == cleanParticipant )
46- this . diagramBuilder . AppendLineFormat ( "participant {0}" , participant ) ;
47+ this . DiagramBuilder . AppendLineFormat ( "participant {0}" , participant ) ;
4748 else
48- this . diagramBuilder . AppendLineFormat ( "participant \" {0}\" as {1}" , participant , cleanParticipant ) ;
49+ this . DiagramBuilder . AppendLineFormat ( "participant \" {0}\" as {1}" , participant , cleanParticipant ) ;
4950 }
5051
5152 /// <summary>
5253 /// Appends a divider with specified text to the sequence diagram
5354 /// </summary>
54- public void Divider ( string text ) => this . diagramBuilder . AppendLineFormat ( "== {0} ==" , text ) ;
55+ public void Divider ( string text ) => this . DiagramBuilder . AppendLineFormat ( "== {0} ==" , text ) ;
5556
5657 /// <summary>
5758 /// Appends a note over one or many participants to the sequence diagram
5859 /// </summary>
5960 public void NoteOver ( string noteText , string startParticipant , string ? endParticipant = null , string ? prefix = null , string ? color = null ) =>
60- this . diagramBuilder . AppendLineFormat (
61+ this . DiagramBuilder . AppendLineFormat (
6162 prefix + """
6263 note over {0}{1}{2}
6364 {3}
@@ -71,7 +72,7 @@ end note
7172 /// <summary>
7273 /// Appends applying a tag to the specified branch/participant to the sequence diagram
7374 /// </summary>
74- public void ApplyTag ( string tag , string toBranch ) => this . diagramBuilder . AppendLineFormat ( "{0} -> {0}: tag {1}" , GetParticipant ( toBranch ) , tag ) ;
75+ public void ApplyTag ( string tag , string toBranch ) => this . DiagramBuilder . AppendLineFormat ( "{0} -> {0}: tag {1}" , GetParticipant ( toBranch ) , tag ) ;
7576
7677 /// <summary>
7778 /// Appends branching from a branch to another branch, @as can override the participant name
@@ -80,11 +81,11 @@ public void BranchTo(string branchName, string currentName, string? @as)
8081 {
8182 if ( ! this . participants . ContainsKey ( branchName ) )
8283 {
83- this . diagramBuilder . Append ( "create " ) ;
84+ this . DiagramBuilder . Append ( "create " ) ;
8485 Participant ( branchName , @as ) ;
8586 }
8687
87- this . diagramBuilder . AppendLineFormat (
88+ this . DiagramBuilder . AppendLineFormat (
8889 "{0} -> {1}: branch from {2}" ,
8990 GetParticipant ( currentName ) ,
9091 GetParticipant ( branchName ) , currentName ) ;
@@ -97,32 +98,32 @@ public void BranchToFromTag(string branchName, string fromTag, string onBranch,
9798 {
9899 if ( ! this . participants . ContainsKey ( branchName ) )
99100 {
100- this . diagramBuilder . Append ( "create " ) ;
101+ this . DiagramBuilder . Append ( "create " ) ;
101102 Participant ( branchName , @as ) ;
102103 }
103104
104- this . diagramBuilder . AppendLineFormat ( "{0} -> {1}: branch from tag ({2})" , GetParticipant ( onBranch ) , GetParticipant ( branchName ) , fromTag ) ;
105+ this . DiagramBuilder . AppendLineFormat ( "{0} -> {1}: branch from tag ({2})" , GetParticipant ( onBranch ) , GetParticipant ( branchName ) , fromTag ) ;
105106 }
106107
107108 /// <summary>
108109 /// Appends a commit on the target participant/branch to the sequence diagram
109110 /// </summary>
110- public void MakeACommit ( string toParticipant ) => this . diagramBuilder . AppendLineFormat ( "{0} -> {0}: commit" , GetParticipant ( toParticipant ) ) ;
111+ public void MakeACommit ( string toParticipant ) => this . DiagramBuilder . AppendLineFormat ( "{0} -> {0}: commit" , GetParticipant ( toParticipant ) ) ;
111112
112113 /// <summary>
113114 /// Append a merge to the sequence diagram
114115 /// </summary>
115- public void Merge ( string from , string to ) => this . diagramBuilder . AppendLineFormat ( "{0} -> {1}: merge" , GetParticipant ( from ) , GetParticipant ( to ) ) ;
116+ public void Merge ( string from , string to ) => this . DiagramBuilder . AppendLineFormat ( "{0} -> {1}: merge" , GetParticipant ( from ) , GetParticipant ( to ) ) ;
116117
117- private string GetParticipant ( string branch ) => this . participants . GetValueOrDefault ( branch , branch ) ;
118+ public string GetParticipant ( string branch ) => this . participants . GetValueOrDefault ( branch , branch ) ;
118119
119120 /// <summary>
120121 /// Ends the sequence diagram
121122 /// </summary>
122- public void End ( ) => this . diagramBuilder . AppendLine ( "@enduml" ) ;
123+ public void End ( ) => this . DiagramBuilder . AppendLine ( "@enduml" ) ;
123124
124125 /// <summary>
125126 /// returns the plantUML representation of the Sequence Diagram
126127 /// </summary>
127- public string GetDiagram ( ) => this . diagramBuilder . ToString ( ) ;
128+ public string GetDiagram ( ) => this . DiagramBuilder . ToString ( ) ;
128129}
0 commit comments