This repository was archived by the owner on Dec 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +69
-1
lines changed
Structurizr.Core.Tests/Model Expand file tree Collapse file tree 3 files changed +69
-1
lines changed Original file line number Diff line number Diff line change 1- using Xunit ;
1+ using System ;
2+ using Xunit ;
23
34namespace Structurizr . Core . Tests
45{
@@ -82,6 +83,43 @@ public void test_Tags_IncludesTheInteractionStyleWhenSpecified()
8283 Assert . False ( relationship . Tags . Contains ( Tags . Synchronous ) ) ;
8384 Assert . True ( relationship . Tags . Contains ( Tags . Asynchronous ) ) ;
8485 }
86+
87+ [ Fact ]
88+ public void Test_SetUrl_DoesNotThrowAnException_WhenANullUrlIsSpecified ( )
89+ {
90+ Relationship relationship = _softwareSystem1 . Uses ( _softwareSystem2 , "Uses 1" , "Technology" ) ;
91+ relationship . Url = null ;
92+ }
93+
94+ [ Fact ]
95+ public void Test_SetUrl_DoesNotThrowAnException_WhenAnEmptyUrlIsSpecified ( )
96+ {
97+ Relationship relationship = _softwareSystem1 . Uses ( _softwareSystem2 , "Uses 1" , "Technology" ) ;
98+ relationship . Url = "" ;
99+ }
100+
101+ [ Fact ]
102+ public void Test_SetUrl_ThrowsAnException_WhenAnInvalidUrlIsSpecified ( )
103+ {
104+ try
105+ {
106+ Relationship relationship = _softwareSystem1 . Uses ( _softwareSystem2 , "Uses 1" , "Technology" ) ;
107+ relationship . Url = "www.somedomain.com" ;
108+ throw new TestFailedException ( ) ;
109+ }
110+ catch ( Exception e )
111+ {
112+ Assert . Equal ( "www.somedomain.com is not a valid URL." , e . Message ) ;
113+ }
114+ }
115+
116+ [ Fact ]
117+ public void Test_SetUrl_DoesNotThrowAnException_WhenAValidUrlIsSpecified ( )
118+ {
119+ Relationship relationship = _softwareSystem1 . Uses ( _softwareSystem2 , "Uses 1" , "Technology" ) ;
120+ relationship . Url = "http://www.somedomain.com" ;
121+ Assert . Equal ( "http://www.somedomain.com" , relationship . Url ) ;
122+ }
85123
86124 }
87125}
Original file line number Diff line number Diff line change @@ -110,6 +110,35 @@ public InteractionStyle InteractionStyle
110110 _interactionStyle = value ;
111111 }
112112 }
113+
114+ private string _url ;
115+
116+ /// <summary>
117+ /// The URL where more information about this relationship can be found.
118+ /// </summary>
119+ [ DataMember ( Name = "url" , EmitDefaultValue = false ) ]
120+ public string Url
121+ {
122+ get
123+ {
124+ return _url ;
125+ }
126+
127+ set
128+ {
129+ if ( value != null && value . Trim ( ) . Length > 0 )
130+ {
131+ if ( Util . Url . IsUrl ( value ) )
132+ {
133+ this . _url = value ;
134+ }
135+ else
136+ {
137+ throw new ArgumentException ( value + " is not a valid URL." ) ;
138+ }
139+ }
140+ }
141+ }
113142
114143 internal Relationship ( )
115144 {
Original file line number Diff line number Diff line change 55- Added A1 and A0 paper sizes.
66- Adds support for themes.
77- Adds support for tags on deployment nodes.
8+ - Adds support for URLs on relationships.
89
910## 0.9.5 (24th December 2019)
1011
You can’t perform that action at this time.
0 commit comments