forked from structurizr/dotnet
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edc4232
commit ba4bcdf
Showing
4 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Xunit; | ||
|
||
namespace Structurizr.Core.Tests | ||
{ | ||
|
||
public class GroupableElementTests : AbstractTestBase | ||
{ | ||
|
||
[Fact] | ||
public void Test_getGroup_ReturnsNullByDefault() | ||
{ | ||
Person element = Model.AddPerson("Person"); | ||
Assert.Null(element.Group); | ||
} | ||
|
||
[Fact] | ||
public void Test_setGroup() | ||
{ | ||
Person element = Model.AddPerson("Person"); | ||
element.Group = "Group"; | ||
Assert.Equal("Group", element.Group); | ||
} | ||
|
||
[Fact] | ||
public void Test_setGroup_TrimsWhiteSpace() | ||
{ | ||
Person element = Model.AddPerson("Person"); | ||
element.Group = " Group "; | ||
Assert.Equal("Group", element.Group); | ||
} | ||
|
||
[Fact] | ||
public void Test_setGroup_HandlesEmptyAndNullValues() | ||
{ | ||
Person element = Model.AddPerson("Person"); | ||
element.Group = "Group"; | ||
|
||
element.Group = null; | ||
Assert.Null(element.Group); | ||
|
||
element.Group = "Group"; | ||
element.Group = ""; | ||
Assert.Null(element.Group); | ||
|
||
element.Group = "Group"; | ||
element.Group = " "; | ||
Assert.Null(element.Group); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Structurizr | ||
{ | ||
|
||
public abstract class GroupableElement : Element | ||
{ | ||
|
||
private string _group; | ||
|
||
/// <summary> | ||
/// The name of the group in which this element should be included in. | ||
/// </summary> | ||
[DataMember(Name = "group", EmitDefaultValue = false)] | ||
public string Group | ||
{ | ||
get | ||
{ | ||
return _group; | ||
} | ||
|
||
set | ||
{ | ||
if (value == null) | ||
{ | ||
_group = null; | ||
} | ||
else { | ||
_group = value.Trim(); | ||
|
||
if (String.IsNullOrEmpty(_group)) | ||
{ | ||
_group = null; | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters