diff --git a/Structurizr.Core.Tests/Model/DeploymentNodeTests.cs b/Structurizr.Core.Tests/Model/DeploymentNodeTests.cs index fc10e79..dc352c3 100644 --- a/Structurizr.Core.Tests/Model/DeploymentNodeTests.cs +++ b/Structurizr.Core.Tests/Model/DeploymentNodeTests.cs @@ -52,9 +52,24 @@ public void test_getRequiredTags() public void test_getTags() { DeploymentNode deploymentNode = new DeploymentNode(); - Assert.Equal("", deploymentNode.Tags); + Assert.Equal("Element,Deployment Node", deploymentNode.Tags); } + + [Fact] + public void Test_RemoveTags_DoesNotRemoveRequiredTags() + { + DeploymentNode deploymentNode = new DeploymentNode(); + Assert.True(deploymentNode.Tags.Contains(Tags.Element)); + Assert.True(deploymentNode.Tags.Contains(Tags.DeploymentNode)); + + deploymentNode.RemoveTag(Tags.DeploymentNode); + deploymentNode.RemoveTag(Tags.Element); + + Assert.True(deploymentNode.Tags.Contains(Tags.Element)); + Assert.True(deploymentNode.Tags.Contains(Tags.DeploymentNode)); + } + [Fact] public void test_add_ThrowsAnException_WhenAContainerIsNotSpecified() { diff --git a/Structurizr.Core/Model/DeploymentNode.cs b/Structurizr.Core/Model/DeploymentNode.cs index 2ebfe78..d32eda8 100644 --- a/Structurizr.Core/Model/DeploymentNode.cs +++ b/Structurizr.Core/Model/DeploymentNode.cs @@ -84,20 +84,13 @@ internal DeploymentNode() Environment = DefaultDeploymentEnvironment; } - public override string Tags { - get - { - return ""; - } - set - { - // no-op - } - } - public override List GetRequiredTags() { - return new List(); + return new List + { + Structurizr.Tags.Element, + Structurizr.Tags.DeploymentNode + }; } public override string CanonicalName diff --git a/Structurizr.Core/Model/ModelItem.cs b/Structurizr.Core/Model/ModelItem.cs index b83962d..8ea8223 100644 --- a/Structurizr.Core/Model/ModelItem.cs +++ b/Structurizr.Core/Model/ModelItem.cs @@ -27,7 +27,7 @@ public IEnumerable GetAllTags() } [DataMember(Name = "tags", EmitDefaultValue = false)] - public virtual string Tags + public string Tags { get { diff --git a/Structurizr.Core/Model/Tags.cs b/Structurizr.Core/Model/Tags.cs index 8491558..673a414 100644 --- a/Structurizr.Core/Model/Tags.cs +++ b/Structurizr.Core/Model/Tags.cs @@ -14,6 +14,7 @@ public sealed class Tags public const string Synchronous = "Synchronous"; public const string Asynchronous = "Asynchronous"; + public const string DeploymentNode = "Deployment Node"; public const string ContainerInstance = "Container Instance"; } diff --git a/Structurizr.Examples/BigBankPlc.cs b/Structurizr.Examples/BigBankPlc.cs index 005e661..ff640a4 100644 --- a/Structurizr.Examples/BigBankPlc.cs +++ b/Structurizr.Examples/BigBankPlc.cs @@ -114,13 +114,13 @@ public static Workspace Create() .AddDeploymentNode("Database Server", "A development database.", "Oracle 12c") .Add(database); - developerLaptop.AddDeploymentNode("Web Browser", "", "Google Chrome, Mozilla Firefox, Apple Safari or Microsoft Edge").Add(singlePageApplication); + developerLaptop.AddDeploymentNode("Web Browser", "", "Chrome, Firefox, Safari, or Edge").Add(singlePageApplication); DeploymentNode customerMobileDevice = model.AddDeploymentNode("Live", "Customer's mobile device", "", "Apple iOS or Android"); customerMobileDevice.Add(mobileApp); DeploymentNode customerComputer = model.AddDeploymentNode("Live", "Customer's computer", "", "Microsoft Windows or Apple macOS"); - customerComputer.AddDeploymentNode("Web Browser", "", "Google Chrome, Mozilla Firefox, Apple Safari or Microsoft Edge").Add(singlePageApplication); + customerComputer.AddDeploymentNode("Web Browser", "", "Chrome, Firefox, Safari, or Edge").Add(singlePageApplication); DeploymentNode bigBankDataCenter = model.AddDeploymentNode("Live", "Big Bank plc", "", "Big Bank plc data center"); @@ -135,9 +135,11 @@ public static Workspace Create() DeploymentNode primaryDatabaseServer = bigBankDataCenter.AddDeploymentNode("bigbank-db01", "The primary database server.", "Ubuntu 16.04 LTS", 1, DictionaryUtils.Create("Location=London")) .AddDeploymentNode("Oracle - Primary", "The primary, live database server.", "Oracle 12c"); primaryDatabaseServer.Add(database); - - DeploymentNode secondaryDatabaseServer = bigBankDataCenter.AddDeploymentNode("bigbank-db02", "The secondary database server.", "Ubuntu 16.04 LTS", 1, DictionaryUtils.Create("Location=Reading")) - .AddDeploymentNode("Oracle - Secondary", "A secondary, standby database server, used for failover purposes only.", "Oracle 12c"); + + DeploymentNode bigBankdb02 = bigBankDataCenter.AddDeploymentNode("bigbank-db02", "The secondary database server.", "Ubuntu 16.04 LTS", 1, DictionaryUtils.Create("Location=Reading")); + bigBankdb02.AddTags(FailoverTag); + DeploymentNode secondaryDatabaseServer = bigBankdb02.AddDeploymentNode("Oracle - Secondary", "A secondary, standby database server, used for failover purposes only.", "Oracle 12c"); + secondaryDatabaseServer.AddTags(FailoverTag); ContainerInstance secondaryDatabase = secondaryDatabaseServer.Add(database); model.Relationships.Where(r=>r.Destination.Equals(secondaryDatabase)).ToList().ForEach(r=>r.AddTags(FailoverTag)); diff --git a/docs/changelog.md b/docs/changelog.md index bae51be..660a83f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,7 @@ - Added A1 and A0 paper sizes. - Adds support for themes. +- Adds support for tags on deployment nodes. ## 0.9.5 (24th December 2019)