This repository was archived by the owner on Dec 23, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#47 Add new C4PlantUmlWriter with C4-PlantUML support
- Add new C4PlantUmlWriter with C4-PlantUML support (issue #47) - ModelItem returns a list of all tags via GetAllTag() - RelationshipView support an additional list of tags which can be used in the diagram via ViewTags. RelationshipView.GetAllTag() returns a merged list of ViewTags and all Relationship tags - Update relationship descriptions and technology in BigBankPlc example - Update PlantUMLWriterTests and C4PlantUmlWriterTests that the expected text can be (simpler) reused as UML definition
- Loading branch information
KIRCHSTH
authored and
KIRCHSTH
committed
Oct 15, 2019
1 parent
d1c04e7
commit 0057342
Showing
20 changed files
with
2,521 additions
and
182 deletions.
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,69 @@ | ||
# Set the default behavior, in case people don't have core.autocrlf set. | ||
* text=auto | ||
|
||
# Explicitly declare text files you want to always be normalized and converted | ||
# to native line endings on checkout. | ||
#*.ts text | ||
|
||
# Shell scripts should always have lf line endings | ||
*.sh text eol=lf | ||
sources.list text eol=lf | ||
|
||
#### Visual Studio specific stuff | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just comment the entries below and | ||
# uncomment the group further below | ||
############################################################################### | ||
*.sln text eol=crlf | ||
*.csproj text eol=crlf | ||
*.vbproj text eol=crlf | ||
*.vcxproj text eol=crlf | ||
*.vcproj text eol=crlf | ||
*.dbproj text eol=crlf | ||
*.fsproj text eol=crlf | ||
*.lsproj text eol=crlf | ||
*.wixproj text eol=crlf | ||
*.modelproj text eol=crlf | ||
*.sqlproj text eol=crlf | ||
*.wmaproj text eol=crlf | ||
|
||
*.xproj text eol=crlf | ||
*.props text eol=crlf | ||
*.filters text eol=crlf | ||
*.vcxitems text eol=crlf | ||
|
||
*.sln merge=binary | ||
*.csproj merge=binary | ||
*.vbproj merge=binary | ||
*.vcxproj merge=binary | ||
*.vcproj merge=binary | ||
*.dbproj merge=binary | ||
*.fsproj merge=binary | ||
*.lsproj merge=binary | ||
*.wixproj merge=binary | ||
*.modelproj merge=binary | ||
*.sqlproj merge=binary | ||
*.wmaproj merge=binary | ||
|
||
*.xproj merge=binary | ||
*.props merge=binary | ||
*.filters merge=binary | ||
*.vcxitems merge=binary | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace Structurizr.Core.Tests | ||
{ | ||
public class ModelItemTests : AbstractTestBase | ||
{ | ||
[Fact] | ||
public void Test_GetAllTags_NoTagAdded_RequiredTagsAreReturned() | ||
{ | ||
Person user = Model.AddPerson("Person", "Description"); | ||
SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "Description"); | ||
var relation = user.Uses(softwareSystem, "Uses", ""); | ||
// Relationship.GetRequiredTags() == new List<string> { Structurizr.Tags.Relationship, Structurizr.Tags.Synchronous } | ||
Assert.Equal(new List<string> { Structurizr.Tags.Relationship, Structurizr.Tags.Synchronous }, relation.GetAllTags()); | ||
} | ||
|
||
[Fact] | ||
public void Test_GetAllTags_TagsAdded_AddedTagsAndRequiredTagsAreReturned() | ||
{ | ||
Person user = Model.AddPerson("Person", "Description"); | ||
SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "Description"); | ||
var relation = user.Uses(softwareSystem, "Uses", ""); | ||
relation.AddTags("TagA","TagB"); | ||
// Relationship.GetRequiredTags() == new List<string> { Structurizr.Tags.Relationship, Structurizr.Tags.Synchronous } | ||
Assert.Equal(new List<string> { Structurizr.Tags.Relationship, Structurizr.Tags.Synchronous, "TagA","TagB" }, relation.GetAllTags()); | ||
} | ||
} | ||
} |
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,26 @@ | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace Structurizr.Core.Tests.View | ||
{ | ||
public class RelationshipViewTests : AbstractTestBase | ||
{ | ||
[Fact] | ||
public void Test_GetAllTags_RelationshipViewTagsAdded_AddedViewTagsAndAllRelationTagsAreReturned() | ||
{ | ||
Person user = Model.AddPerson("Person", "Description"); | ||
SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "Description"); | ||
var relation = user.Uses(softwareSystem, "Uses", ""); | ||
relation.AddTags("TagA","TagB"); | ||
|
||
var relationView = new RelationshipView(relation); | ||
relationView.AddViewTags("Rel_Left", "AnotherLayoutTag"); | ||
|
||
// var expected = new List<string>(relation.GetAllTags()) {"Rel_Left", "AnotherLayoutTag"}; | ||
var expected = new List<string>{"Rel_Left", "AnotherLayoutTag"}; | ||
expected.AddRange(relation.GetAllTags()); | ||
|
||
Assert.Equal(expected, relationView.GetAllTags()); | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using Structurizr.IO.C4PlantUML; | ||
|
||
namespace Structurizr.Examples | ||
{ | ||
/// <summary> | ||
/// An example of how to use the C4PlantUML writer. Run this program and copy/paste | ||
/// the output into http://www.plantuml.com/plantuml/ | ||
/// </summary> | ||
public class C4PlantUML | ||
{ | ||
static void Main() | ||
{ | ||
Workspace workspace = new Workspace("Getting Started", "This is a model of my software system."); | ||
Model model = workspace.Model; | ||
|
||
model.Enterprise = new Enterprise("Some Enterprise"); | ||
|
||
Person user = model.AddPerson("User", "A user of my software system."); | ||
SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system."); | ||
var userUsesSystemRelation = user.Uses(softwareSystem, "Uses"); | ||
// layout could be added to relation (active in all views) | ||
// userUsesSystemRelation.AddTags(C4PlantUmlWriter.Tags.Rel_Right); | ||
|
||
ViewSet views = workspace.Views; | ||
SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); | ||
contextView.AddAllSoftwareSystems(); | ||
contextView.AddAllPeople(); | ||
|
||
// C4PlantUMLWriter support relation layouts tags, e.g. "User" should be left of "Software System" in view | ||
contextView.Relationships | ||
.First(rv => rv.Relationship.SourceId == user.Id && rv.Relationship.DestinationId == softwareSystem.Id) | ||
.AddViewTags(C4PlantUmlWriter.Tags.Rel_Right); | ||
|
||
using (var stringWriter = new StringWriter()) | ||
{ | ||
var plantUmlWriter = new C4PlantUmlWriter(); | ||
plantUmlWriter.Write(workspace, stringWriter); | ||
Console.WriteLine(stringWriter.ToString()); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.