示例#1
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)));
        }
示例#2
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);
            }
        }
        public void Test_GetInfrastructureNodeWithName_ReturnsTheNamedDeploymentNode_WhenThereIsAInfrastructureNodeWithTheSpecifiedName()
        {
            DeploymentNode     parent = Model.AddDeploymentNode("parent", "", "");
            InfrastructureNode child  = parent.AddInfrastructureNode("child", "", "");

            Assert.Same(child, parent.GetInfrastructureNodeWithName("child"));
        }
示例#4
0
        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);
        }
示例#5
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)));
        }
        static void Main()
        {
            Workspace workspace = new Workspace("Amazon Web Services Example", "An example AWS deployment architecture.");
            Model     model     = workspace.Model;

            SoftwareSystem softwareSystem = model.AddSoftwareSystem("Spring PetClinic", "Allows employees to view and manage information regarding the veterinarians, the clients, and their pets.");
            Container      webApplication = softwareSystem.AddContainer("Web Application", "Allows employees to view and manage information regarding the veterinarians, the clients, and their pets.", "Java and Spring Boot");

            webApplication.AddTags(SpringBootTag);
            Container database = softwareSystem.AddContainer("Database", "Stores information regarding the veterinarians, the clients, and their pets.", "Relational database schema");

            database.AddTags(DatabaseTag);

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

            DeploymentNode amazonWebServices = model.AddDeploymentNode("Amazon Web Services");

            amazonWebServices.AddTags("Amazon Web Services - Cloud");
            DeploymentNode amazonRegion = amazonWebServices.AddDeploymentNode("US-East-1");

            amazonRegion.AddTags("Amazon Web Services - Region");
            DeploymentNode autoscalingGroup = amazonRegion.AddDeploymentNode("Autoscaling group");

            autoscalingGroup.AddTags("Amazon Web Services - Auto Scaling");
            DeploymentNode ec2 = autoscalingGroup.AddDeploymentNode("Amazon EC2");

            ec2.AddTags("Amazon Web Services - EC2");
            ContainerInstance webApplicationInstance = ec2.Add(webApplication);

            InfrastructureNode route53 = amazonRegion.AddInfrastructureNode("Route 53");

            route53.AddTags("Amazon Web Services - Route 53");

            InfrastructureNode elb = amazonRegion.AddInfrastructureNode("Elastic Load Balancer");

            elb.AddTags("Amazon Web Services - Elastic Load Balancing");

            route53.Uses(elb, "Forwards requests to", "HTTPS");
            elb.Uses(webApplicationInstance, "Forwards requests to", "HTTPS");

            DeploymentNode rds = amazonRegion.AddDeploymentNode("Amazon RDS");

            rds.AddTags("Amazon Web Services - RDS");
            DeploymentNode mySql = rds.AddDeploymentNode("MySQL");

            mySql.AddTags("Amazon Web Services - RDS_MySQL_instance");
            ContainerInstance databaseInstance = mySql.Add(database);

            ViewSet        views          = workspace.Views;
            DeploymentView deploymentView = views.CreateDeploymentView(softwareSystem, "AmazonWebServicesDeployment", "An example deployment diagram.");

            deploymentView.AddAllDeploymentNodes();

            deploymentView.AddAnimation(route53);
            deploymentView.AddAnimation(elb);
            deploymentView.AddAnimation(webApplicationInstance);
            deploymentView.AddAnimation(databaseInstance);

            Styles styles = views.Configuration.Styles;

            styles.Add(new ElementStyle(SpringBootTag)
            {
                Shape = Shape.RoundedBox, Background = "#ffffff"
            });
            styles.Add(new ElementStyle(DatabaseTag)
            {
                Shape = Shape.Cylinder, Background = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.InfrastructureNode)
            {
                Shape = Shape.RoundedBox, Background = "#ffffff"
            });

            views.Configuration.Theme = "https://raw.githubusercontent.com/structurizr/themes/master/amazon-web-services/theme.json";

            StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret);

            structurizrClient.PutWorkspace(WorkspaceId, workspace);
        }