Exemple #1
0
        public void Test_AddElementInstance_AddsElementInstancesAndReplicatesRelationshipsWithinTheDeploymentEnvironmentAndDefaultGroup()
        {
            SoftwareSystem softwareSystem1 = Model.AddSoftwareSystem("Software System");
            Container      api             = softwareSystem1.AddContainer("API");
            Container      database        = softwareSystem1.AddContainer("Database");

            api.Uses(database, "Uses");

            DeploymentNode    liveDeploymentNode = Model.AddDeploymentNode("Live", "Deployment Node", "Description", "Technology");
            ContainerInstance apiInstance1       = liveDeploymentNode.Add(api);
            ContainerInstance databaseInstance1  = liveDeploymentNode.Add(database);

            ContainerInstance apiInstance2      = liveDeploymentNode.Add(api);
            ContainerInstance databaseInstance2 = liveDeploymentNode.Add(database);

            Assert.Equal(2, apiInstance1.Relationships.Count);
            Assert.Equal(2, apiInstance2.Relationships.Count);

            // apiInstance1 -> databaseInstance1
            Relationship relationship = apiInstance1.GetEfferentRelationshipWith(databaseInstance1);

            Assert.Equal("Uses", relationship.Description);

            // apiInstance1 -> databaseInstance2
            relationship = apiInstance1.GetEfferentRelationshipWith(databaseInstance2);
            Assert.Equal("Uses", relationship.Description);

            // apiInstance2 -> databaseInstance1
            relationship = apiInstance2.GetEfferentRelationshipWith(databaseInstance1);
            Assert.Equal("Uses", relationship.Description);

            // apiInstance2 -> databaseInstance2
            relationship = apiInstance2.GetEfferentRelationshipWith(databaseInstance2);
            Assert.Equal("Uses", relationship.Description);
        }
        public void Test_AddAnimationStep_ThrowsAnException_WhenContainerInstancesAreSpecifiedButNoneOfThemExistInTheView()
        {
            try
            {
                SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "");
                Container      webApplication = softwareSystem.AddContainer("Web Application", "Description", "Technology");
                Container      database       = softwareSystem.AddContainer("Database", "Description", "Technology");
                webApplication.Uses(database, "Reads from and writes to", "JDBC/HTTPS");

                DeploymentNode    developerLaptop        = Model.AddDeploymentNode("Developer Laptop", "Description", "Technology");
                DeploymentNode    apacheTomcat           = developerLaptop.AddDeploymentNode("Apache Tomcat", "Description", "Technology");
                DeploymentNode    oracle                 = developerLaptop.AddDeploymentNode("Oracle", "Description", "Technology");
                ContainerInstance webApplicationInstance = apacheTomcat.Add(webApplication);
                ContainerInstance databaseInstance       = oracle.Add(database);

                deploymentView = Views.CreateDeploymentView(softwareSystem, "deployment", "Description");

                deploymentView.AddAnimation(webApplicationInstance, databaseInstance);
                throw new TestFailedException();
            }
            catch (ArgumentException ae)
            {
                Assert.Equal("None of the specified container instances exist in this view.", ae.Message);
            }
        }
Exemple #3
0
        public void test_getDeploymentNodeWithName_ReturnsTheNamedDeploymentNode_WhenThereIsADeploymentWithTheSpecifiedName()
        {
            DeploymentNode parent = Model.AddDeploymentNode("parent", "", "");
            DeploymentNode child  = parent.AddDeploymentNode("child", "", "");

            Assert.Same(child, parent.GetDeploymentNodeWithName("child"));
        }
Exemple #4
0
        public void Test_AddElementInstance_AddsElementInstancesAndReplicatesRelationshipsWithinTheDeploymentEnvironmentAndSpecifiedGroup()
        {
            // in this test, container instances are added to two deployment groups: "Service 1" and "Service 2"
            // relationships are not replicated between element instances in other groups

            SoftwareSystem softwareSystem1 = Model.AddSoftwareSystem("Software System");
            Container      api             = softwareSystem1.AddContainer("API");
            Container      database        = softwareSystem1.AddContainer("Database");

            api.Uses(database, "Uses");

            DeploymentNode    liveDeploymentNode = Model.AddDeploymentNode("Live", "Deployment Node", "Description", "Technology");
            ContainerInstance apiInstance1       = liveDeploymentNode.Add(api, "Service 1");
            ContainerInstance databaseInstance1  = liveDeploymentNode.Add(database, "Service 1");

            ContainerInstance apiInstance2      = liveDeploymentNode.Add(api, "Service 2");
            ContainerInstance databaseInstance2 = liveDeploymentNode.Add(database, "Service 2");

            Assert.Equal(1, apiInstance1.Relationships.Count);
            Assert.Equal(1, apiInstance2.Relationships.Count);

            // apiInstance1 -> databaseInstance1
            Relationship relationship = apiInstance1.GetEfferentRelationshipWith(databaseInstance1);

            Assert.Equal("Uses", relationship.Description);

            // apiInstance2 -> databaseInstance2
            relationship = apiInstance2.GetEfferentRelationshipWith(databaseInstance2);
            Assert.Equal("Uses", relationship.Description);
        }
        private void Write(DeploymentNode deploymentNode, TextWriter writer, int indent)
        {
            writer.Write(
                String.Format("{0}node \"{1}\" <<{2}>> as {3} {{",
                              CalculateIndent(indent),
                              deploymentNode.Name + (deploymentNode.Instances > 1 ? " (x" + deploymentNode.Instances + ")" : ""),
                              TypeOf(deploymentNode),
                              deploymentNode.Id
                              )
                );

            writer.Write(Environment.NewLine);

            foreach (DeploymentNode child in deploymentNode.Children)
            {
                Write(child, writer, indent + 1);
            }

            foreach (ContainerInstance containerInstance in deploymentNode.ContainerInstances)
            {
                Write(containerInstance, writer, indent + 1);
            }

            writer.Write(
                String.Format("{0}}}", CalculateIndent(indent))
                );
            writer.Write(Environment.NewLine);
        }
        public void Test_GetInfrastructureNodeWithName_ReturnsTheNamedDeploymentNode_WhenThereIsAInfrastructureNodeWithTheSpecifiedName()
        {
            DeploymentNode     parent = Model.AddDeploymentNode("parent", "", "");
            InfrastructureNode child  = parent.AddInfrastructureNode("child", "", "");

            Assert.Same(child, parent.GetInfrastructureNodeWithName("child"));
        }
        public void Test_AddAnimationStep_IgnoresContainerInstancesThatDoNotExistInTheView()
        {
            SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "");
            Container      webApplication = softwareSystem.AddContainer("Web Application", "Description", "Technology");
            Container      database       = softwareSystem.AddContainer("Database", "Description", "Technology");

            webApplication.Uses(database, "Reads from and writes to", "JDBC/HTTPS");

            DeploymentNode    developerLaptop        = Model.AddDeploymentNode("Developer Laptop", "Description", "Technology");
            DeploymentNode    apacheTomcat           = developerLaptop.AddDeploymentNode("Apache Tomcat", "Description", "Technology");
            DeploymentNode    oracle                 = developerLaptop.AddDeploymentNode("Oracle", "Description", "Technology");
            ContainerInstance webApplicationInstance = apacheTomcat.Add(webApplication);
            ContainerInstance databaseInstance       = oracle.Add(database);

            deploymentView = Views.CreateDeploymentView(softwareSystem, "deployment", "Description");
            deploymentView.Add(apacheTomcat);

            deploymentView.AddAnimation(webApplicationInstance, databaseInstance);

            Animation step1 = deploymentView.Animations.First(step => step.Order == 1);

            Assert.Equal(3, step1.Elements.Count);
            Assert.True(step1.Elements.Contains(developerLaptop.Id));
            Assert.True(step1.Elements.Contains(apacheTomcat.Id));
            Assert.True(step1.Elements.Contains(webApplicationInstance.Id));
            Assert.Equal(0, step1.Relationships.Count);
        }
Exemple #8
0
        public void test_addDeploymentNode_AddsAChildDeploymentNode_WhenANameIsSpecified()
        {
            DeploymentNode parent = Model.AddDeploymentNode("Parent", "", "");

            DeploymentNode child = parent.AddDeploymentNode("Child 1", "Description", "Technology");

            Assert.NotNull(child);
            Assert.Equal("Child 1", child.Name);
            Assert.Equal("Description", child.Description);
            Assert.Equal("Technology", child.Technology);
            Assert.Equal(1, child.Instances);
            Assert.Equal(0, child.Properties.Count);
            Assert.True(parent.Children.Contains(child));

            child = parent.AddDeploymentNode("Child 2", "Description", "Technology", 4);
            Assert.NotNull(child);
            Assert.Equal("Child 2", child.Name);
            Assert.Equal("Description", child.Description);
            Assert.Equal("Technology", child.Technology);
            Assert.Equal(4, child.Instances);
            Assert.Equal(0, child.Properties.Count);
            Assert.True(parent.Children.Contains(child));

            child = parent.AddDeploymentNode("Child 3", "Description", "Technology", 4, DictionaryUtils.Create("name=value"));
            Assert.NotNull(child);
            Assert.Equal("Child 3", child.Name);
            Assert.Equal("Description", child.Description);
            Assert.Equal("Technology", child.Technology);
            Assert.Equal(4, child.Instances);
            Assert.Equal(1, child.Properties.Count);
            Assert.Equal("value", child.Properties["name"]);
            Assert.True(parent.Children.Contains(child));
        }
Exemple #9
0
        public void test_getCanonicalName_WhenTheDeploymentNodeHasNoParent()
        {
            DeploymentNode deploymentNode = new DeploymentNode();

            deploymentNode.Name = "Ubuntu Server";

            Assert.Equal("/Deployment/Default/Ubuntu Server", deploymentNode.CanonicalName);
        }
        public void Test_Instances()
        {
            DeploymentNode deploymentNode = new DeploymentNode();

            deploymentNode.Instances = 8;

            Assert.Equal(8, deploymentNode.Instances);
        }
Exemple #11
0
 public void test_getDeploymentNodeWithName_ThrowsAnException_WhenANameIsNotSpecified()
 {
     try {
         DeploymentNode deploymentNode = new DeploymentNode();
         deploymentNode.GetDeploymentNodeWithName(null);
         throw new TestFailedException();
     } catch (ArgumentException ae) {
         Assert.Equal("A name must be specified.", ae.Message);
     }
 }
Exemple #12
0
 public void test_uses_ThrowsAnException_WhenANullDestinationIsSpecified()
 {
     try {
         DeploymentNode deploymentNode = Model.AddDeploymentNode("Deployment Node", "", "");
         deploymentNode.Uses(null, "", "");
         throw new TestFailedException();
     } catch (ArgumentException ae) {
         Assert.Equal("The destination must be specified.", ae.Message);
     }
 }
Exemple #13
0
 public void test_add_ThrowsAnException_WhenAContainerIsNotSpecified()
 {
     try {
         DeploymentNode deploymentNode = new DeploymentNode();
         deploymentNode.Add(null);
         throw new TestFailedException();
     } catch (ArgumentException ae) {
         Assert.Equal("A container must be specified.", ae.Message);
     }
 }
Exemple #14
0
        public void Test_CanonicalName_WhenTheDeploymentNodeHasAParent()
        {
            DeploymentNode l1 = Model.AddDeploymentNode("Level 1", "", "");
            DeploymentNode l2 = l1.AddDeploymentNode("Level 2", "", "");
            DeploymentNode l3 = l2.AddDeploymentNode("Level 3", "", "");

            Assert.Equal("DeploymentNode://Default/Level 1", l1.CanonicalName);
            Assert.Equal("DeploymentNode://Default/Level 1/Level 2", l2.CanonicalName);
            Assert.Equal("DeploymentNode://Default/Level 1/Level 2/Level 3", l3.CanonicalName);
        }
Exemple #15
0
 public void test_addDeploymentNode_ThrowsAnException_WhenANameIsNotSpecified()
 {
     try {
         DeploymentNode parent = Model.AddDeploymentNode("Parent", "", "");
         parent.AddDeploymentNode(null, "", "");
         throw new TestFailedException();
     } catch (ArgumentException ae) {
         Assert.Equal("A name must be specified.", ae.Message);
     }
 }
Exemple #16
0
        public void test_getParent_ReturnsTheParentDeploymentNode()
        {
            DeploymentNode parent = new DeploymentNode();

            Assert.Null(parent.Parent);

            DeploymentNode child = new DeploymentNode();

            child.Parent = parent;
            Assert.Same(parent, child.Parent);
        }
Exemple #17
0
        public void test_add_AddsAContainerInstance_WhenAContainerIsSpecified()
        {
            SoftwareSystem    softwareSystem    = Model.AddSoftwareSystem("Software System", "");
            Container         container         = softwareSystem.AddContainer("Container", "", "");
            DeploymentNode    deploymentNode    = Model.AddDeploymentNode("Deployment Node", "", "");
            ContainerInstance containerInstance = deploymentNode.Add(container);

            Assert.NotNull(containerInstance);
            Assert.Same(container, containerInstance.Container);
            Assert.True(deploymentNode.ContainerInstances.Contains(containerInstance));
        }
        public void Test_AddAllDeploymentNodes_DoesNothing_WhenThereNoDeploymentNodesForTheDeploymentEnvironment()
        {
            SoftwareSystem    softwareSystem    = Model.AddSoftwareSystem("Software System", "");
            Container         container         = softwareSystem.AddContainer("Container", "Description", "Technology");
            DeploymentNode    deploymentNode    = Model.AddDeploymentNode("Deployment Node", "Description", "Technology");
            ContainerInstance containerInstance = deploymentNode.Add(container);

            deploymentView             = Views.CreateDeploymentView(softwareSystem, "deployment", "Description");
            deploymentView.Environment = "Live";
            deploymentView.AddAllDeploymentNodes();
            Assert.Equal(0, deploymentView.Elements.Count);
        }
Exemple #19
0
        public void test_uses_AddsARelationship()
        {
            DeploymentNode primaryNode   = Model.AddDeploymentNode("MySQL - Primary", "", "");
            DeploymentNode secondaryNode = Model.AddDeploymentNode("MySQL - Secondary", "", "");
            Relationship   relationship  = primaryNode.Uses(secondaryNode, "Replicates data to", "Some technology");

            Assert.NotNull(relationship);
            Assert.Same(primaryNode, relationship.Source);
            Assert.Same(secondaryNode, relationship.Destination);
            Assert.Equal("Replicates data to", relationship.Description);
            Assert.Equal("Some technology", relationship.Technology);
        }
Exemple #20
0
        public void Test_AddContainerInstance_AddsAContainerInstance_WhenAContainerIsSpecified()
        {
            DeploymentNode developmentDeploymentNode = Model.AddDeploymentNode("Development", "Deployment Node", "Description", "Technology");
            SoftwareSystem softwareSystem1           = Model.AddSoftwareSystem("Software System 1", "Description");
            Container      container1 = softwareSystem1.AddContainer("Container 1", "Description", "Technology");

            SoftwareSystem softwareSystem2 = Model.AddSoftwareSystem("Software System 2", "Description");
            Container      container2      = softwareSystem2.AddContainer("Container 2", "Description", "Technology");

            SoftwareSystem softwareSystem3 = Model.AddSoftwareSystem("Software System 3", "Description");
            Container      container3      = softwareSystem3.AddContainer("Container 3", "Description", "Technology");

            container1.Uses(container2, "Uses 1", "Technology 1", InteractionStyle.Synchronous);
            container2.Uses(container3, "Uses 2", "Technology 2", InteractionStyle.Asynchronous);

            ContainerInstance containerInstance1 = Model.AddContainerInstance(developmentDeploymentNode, container1);
            ContainerInstance containerInstance2 = Model.AddContainerInstance(developmentDeploymentNode, container2);
            ContainerInstance containerInstance3 = Model.AddContainerInstance(developmentDeploymentNode, container3);

            // the following live container instances should not affect the relationships of the development container instances
            DeploymentNode liveDeploymentNode = Model.AddDeploymentNode("Live", "Deployment Node", "Description", "Technology");

            liveDeploymentNode.Add(container1);
            liveDeploymentNode.Add(container2);
            liveDeploymentNode.Add(container3);

            Assert.Same(container2, containerInstance2.Container);
            Assert.Equal(container2.Id, containerInstance2.ContainerId);
            Assert.Same(softwareSystem2, containerInstance2.Parent);
            Assert.Equal("/Software System 2/Container 2[1]", containerInstance2.CanonicalName);
            Assert.Equal("Container Instance", containerInstance2.Tags);
            Assert.Equal("Development", containerInstance2.Environment);

            Assert.Equal(1, containerInstance1.Relationships.Count);
            Relationship relationship = containerInstance1.Relationships.First();

            Assert.Same(containerInstance1, relationship.Source);
            Assert.Same(containerInstance2, relationship.Destination);
            Assert.Equal("Uses 1", relationship.Description);
            Assert.Equal("Technology 1", relationship.Technology);
            Assert.Equal(InteractionStyle.Synchronous, relationship.InteractionStyle);
            Assert.Equal("", relationship.Tags);

            Assert.Equal(1, containerInstance2.Relationships.Count);
            relationship = containerInstance2.Relationships.First();
            Assert.Same(containerInstance2, relationship.Source);
            Assert.Same(containerInstance3, relationship.Destination);
            Assert.Equal("Uses 2", relationship.Description);
            Assert.Equal("Technology 2", relationship.Technology);
            Assert.Equal(InteractionStyle.Asynchronous, relationship.InteractionStyle);
            Assert.Equal("", relationship.Tags);
        }
Exemple #21
0
        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));
        }
 public void Test_Instances_ThrowsAnException_WhenANegativeNumberIsSpecified()
 {
     try
     {
         DeploymentNode deploymentNode = new DeploymentNode();
         deploymentNode.Instances = -1;
         throw new TestFailedException();
     }
     catch (ArgumentException ae)
     {
         Assert.Equal("Number of instances must be a positive integer.", ae.Message);
     }
 }
Exemple #23
0
        public void test_getCanonicalName_WhenTheDeploymentNodeHasAParent()
        {
            DeploymentNode parent = new DeploymentNode();

            parent.Name = "Ubuntu Server";

            DeploymentNode child = new DeploymentNode();

            child.Name   = "Apache Tomcat";
            child.Parent = parent;

            Assert.Equal("/Deployment/Default/Ubuntu Server/Apache Tomcat", child.CanonicalName);
        }
        public void Test_AddAllDeploymentNodes_AddsDeploymentNodesAndContainerInstances_WhenThereAreTopLevelDeploymentNodesWithContainerInstances()
        {
            SoftwareSystem    softwareSystem    = Model.AddSoftwareSystem("Software System", "");
            Container         container         = softwareSystem.AddContainer("Container", "Description", "Technology");
            DeploymentNode    deploymentNode    = Model.AddDeploymentNode("Deployment Node", "Description", "Technology");
            ContainerInstance containerInstance = deploymentNode.Add(container);

            deploymentView = Views.CreateDeploymentView(softwareSystem, "deployment", "Description");
            deploymentView.AddAllDeploymentNodes();
            Assert.Equal(2, deploymentView.Elements.Count);
            Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNode)));
            Assert.True(deploymentView.Elements.Contains(new ElementView(containerInstance)));
        }
Exemple #25
0
        public void Test_AddInfrastructureNode_ThrowsAnException_WhenAChildInfrastructureNodeWithTheSameNameAlreadyExists()
        {
            DeploymentNode deploymentNode = Model.AddDeploymentNode("Amazon Web Services");

            deploymentNode.AddInfrastructureNode("Node");
            try
            {
                deploymentNode.AddInfrastructureNode("Node");
                throw new TestFailedException();
            }
            catch (ArgumentException iae)
            {
                Assert.Equal("A deployment/infrastructure node named 'Node' already exists.", iae.Message);
            }
        }
Exemple #26
0
        public void Test_Add_AddsTheInfrastructureNode()
        {
            DeploymentNode     deploymentNodeParent = Model.AddDeploymentNode("Deployment Node", "Description", "Technology");
            DeploymentNode     deploymentNodeChild  = deploymentNodeParent.AddDeploymentNode("Deployment Node", "Description", "Technology");
            InfrastructureNode infrastructureNode1  = deploymentNodeChild.AddInfrastructureNode("Infrastructure Node 1");
            InfrastructureNode infrastructureNode2  = deploymentNodeChild.AddInfrastructureNode("Infrastructure Node 2");

            deploymentView = Views.CreateDeploymentView("deployment", "Description");
            deploymentView.Add(infrastructureNode1);

            Assert.Equal(3, deploymentView.Elements.Count);
            Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNodeParent)));
            Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNodeChild)));
            Assert.True(deploymentView.Elements.Contains(new ElementView(infrastructureNode1)));
        }
        public void Test_AddDeploymentNode_AddsTheParentToo()
        {
            SoftwareSystem    softwareSystem       = Model.AddSoftwareSystem("Software System", "");
            Container         container            = softwareSystem.AddContainer("Container", "Description", "Technology");
            DeploymentNode    deploymentNodeParent = Model.AddDeploymentNode("Deployment Node", "Description", "Technology");
            DeploymentNode    deploymentNodeChild  = deploymentNodeParent.AddDeploymentNode("Deployment Node", "Description", "Technology");
            ContainerInstance containerInstance    = deploymentNodeChild.Add(container);

            deploymentView = Views.CreateDeploymentView(softwareSystem, "deployment", "Description");
            deploymentView.Add(deploymentNodeChild);
            Assert.Equal(3, deploymentView.Elements.Count);
            Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNodeParent)));
            Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNodeChild)));
            Assert.True(deploymentView.Elements.Contains(new ElementView(containerInstance)));
        }
        public void Test_Remove_RemovesTheChildDeploymentNodeAndChildren()
        {
            SoftwareSystem     softwareSystem       = Model.AddSoftwareSystem("Software System", "");
            Container          container            = softwareSystem.AddContainer("Container", "Description", "Technology");
            DeploymentNode     deploymentNodeParent = Model.AddDeploymentNode("Deployment Node", "Description", "Technology");
            DeploymentNode     deploymentNodeChild  = deploymentNodeParent.AddDeploymentNode("Deployment Node", "Description", "Technology");
            InfrastructureNode infrastructureNode   = deploymentNodeChild.AddInfrastructureNode("Infrastructure Node");
            ContainerInstance  containerInstance    = deploymentNodeChild.Add(container);

            deploymentView = Views.CreateDeploymentView(softwareSystem, "deployment", "Description");
            deploymentView.AddAllDeploymentNodes();
            Assert.Equal(4, deploymentView.Elements.Count);

            deploymentView.Remove(deploymentNodeParent);
            Assert.Equal(0, deploymentView.Elements.Count);
        }
Exemple #29
0
        public void Test_Add_AddsTheSoftwareSystemInstance()
        {
            SoftwareSystem         softwareSystem         = Model.AddSoftwareSystem("Software System");
            DeploymentNode         deploymentNodeParent   = Model.AddDeploymentNode("Deployment Node", "Description", "Technology");
            DeploymentNode         deploymentNodeChild    = deploymentNodeParent.AddDeploymentNode("Deployment Node", "Description", "Technology");
            InfrastructureNode     infrastructureNode     = deploymentNodeChild.AddInfrastructureNode("Infrastructure Node ");
            SoftwareSystemInstance softwareSystemInstance = deploymentNodeChild.Add(softwareSystem);

            deploymentView = Views.CreateDeploymentView("deployment", "Description");
            deploymentView.Add(softwareSystemInstance);

            Assert.Equal(3, deploymentView.Elements.Count);
            Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNodeParent)));
            Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNodeChild)));
            Assert.True(deploymentView.Elements.Contains(new ElementView(softwareSystemInstance)));
        }
Exemple #30
0
        static void Main()
        {
            Workspace workspace = new Workspace("HTTP-based health checks example", "An example of how to use the HTTP-based health checks feature");
            Model     model     = workspace.Model;
            ViewSet   views     = workspace.Views;

            SoftwareSystem structurizr    = model.AddSoftwareSystem("Structurizr", "A publishing platform for software architecture diagrams and documentation based upon the C4 model.");
            Container      webApplication = structurizr.AddContainer("structurizr.com", "Provides all of the server-side functionality of Structurizr, serving static and dynamic content to users.", "Java and Spring MVC");
            Container      database       = structurizr.AddContainer("Database", "Stores information about users, workspaces, etc.", "Relational Database Schema");

            database.AddTags(DatabaseTag);
            webApplication.Uses(database, "Reads from and writes to", "JDBC");

            DeploymentNode    amazonWebServices  = model.AddDeploymentNode("Amazon Web Services", "", "us-east-1");
            DeploymentNode    pivotalWebServices = amazonWebServices.AddDeploymentNode("Pivotal Web Services", "Platform as a Service provider.", "Cloud Foundry");
            ContainerInstance liveWebApplication = pivotalWebServices.AddDeploymentNode("www.structurizr.com", "An open source Java EE web server.", "Apache Tomcat")
                                                   .Add(webApplication);
            ContainerInstance liveDatabaseInstance = amazonWebServices.AddDeploymentNode("Amazon RDS", "Database as a Service provider.", "MySQL")
                                                     .Add(database);

            // add health checks to the container instances, which return a simple HTTP 200 to say everything is okay
            liveWebApplication.AddHealthCheck("Web Application is running", "https://www.structurizr.com/health");
            liveDatabaseInstance.AddHealthCheck("Database is accessible from Web Application", "https://www.structurizr.com/health/database");

            // the pass/fail status from the health checks is used to supplement any deployment views that include the container instances that have health checks defined
            DeploymentView deploymentView = views.CreateDeploymentView(structurizr, "Deployment", "A deployment diagram showing the live environment.");

            deploymentView.Environment = "Live";
            deploymentView.AddAllDeploymentNodes();

            views.Configuration.Styles.Add(new ElementStyle(Tags.Element)
            {
                Color = "#ffffff"
            });
            views.Configuration.Styles.Add(new ElementStyle(DatabaseTag)
            {
                Shape = Shape.Cylinder
            });

            StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret);

            WorkspaceUtils.PrintWorkspaceAsJson(workspace);
            Console.ReadKey();
            structurizrClient.PutWorkspaceAsync(WorkspaceId, workspace).Wait();
        }