Skip to content

Commit

Permalink
Adds support for URLs on relationships.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Feb 25, 2020
1 parent c4d6e0d commit 450e31b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
40 changes: 39 additions & 1 deletion Structurizr.Core.Tests/Model/RelationshipTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Xunit;
using System;
using Xunit;

namespace Structurizr.Core.Tests
{
Expand Down Expand Up @@ -82,6 +83,43 @@ public void test_Tags_IncludesTheInteractionStyleWhenSpecified()
Assert.False(relationship.Tags.Contains(Tags.Synchronous));
Assert.True(relationship.Tags.Contains(Tags.Asynchronous));
}

[Fact]
public void Test_SetUrl_DoesNotThrowAnException_WhenANullUrlIsSpecified()
{
Relationship relationship = _softwareSystem1.Uses(_softwareSystem2, "Uses 1", "Technology");
relationship.Url = null;
}

[Fact]
public void Test_SetUrl_DoesNotThrowAnException_WhenAnEmptyUrlIsSpecified()
{
Relationship relationship = _softwareSystem1.Uses(_softwareSystem2, "Uses 1", "Technology");
relationship.Url = "";
}

[Fact]
public void Test_SetUrl_ThrowsAnException_WhenAnInvalidUrlIsSpecified()
{
try
{
Relationship relationship = _softwareSystem1.Uses(_softwareSystem2, "Uses 1", "Technology");
relationship.Url = "www.somedomain.com";
throw new TestFailedException();
}
catch (Exception e)
{
Assert.Equal("www.somedomain.com is not a valid URL.", e.Message);
}
}

[Fact]
public void Test_SetUrl_DoesNotThrowAnException_WhenAValidUrlIsSpecified()
{
Relationship relationship = _softwareSystem1.Uses(_softwareSystem2, "Uses 1", "Technology");
relationship.Url = "http://www.somedomain.com";
Assert.Equal("http://www.somedomain.com", relationship.Url);
}

}
}
29 changes: 29 additions & 0 deletions Structurizr.Core/Model/Relationship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,35 @@ public InteractionStyle InteractionStyle
_interactionStyle = value;
}
}

private string _url;

/// <summary>
/// The URL where more information about this relationship can be found.
/// </summary>
[DataMember(Name = "url", EmitDefaultValue = false)]
public string Url
{
get
{
return _url;
}

set
{
if (value != null && value.Trim().Length > 0)
{
if (Util.Url.IsUrl(value))
{
this._url = value;
}
else
{
throw new ArgumentException(value + " is not a valid URL.");
}
}
}
}

internal Relationship()
{
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Added A1 and A0 paper sizes.
- Adds support for themes.
- Adds support for tags on deployment nodes.
- Adds support for URLs on relationships.

## 0.9.5 (24th December 2019)

Expand Down

0 comments on commit 450e31b

Please sign in to comment.