static void Main() { Workspace workspace = new Workspace("Styling Relationships", "This is a model of my software system."); Model model = workspace.Model; Person user = model.AddPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system."); Container webApplication = softwareSystem.AddContainer("Web Application", "My web application.", "Java and Spring MVC"); Container database = softwareSystem.AddContainer("Database", "My database.", "Relational database schema"); user.Uses(webApplication, "Uses", "HTTPS"); webApplication.Uses(database, "Reads from and writes to", "JDBC"); ViewSet views = workspace.Views; ContainerView containerView = views.CreateContainerView(softwareSystem, "containers", "An example of a container diagram."); containerView.AddAllElements(); Styles styles = workspace.Views.Configuration.Styles; // example 1 // styles.Add(new RelationshipStyle(Tags.Relationship) { Color = "#ff0000" }); // example 2 // model.Relationships.Where(r => "HTTPS".Equals(r.Technology)).ToList().ForEach(r => r.AddTags("HTTPS")); // model.Relationships.Where(r => "JDBC".Equals(r.Technology)).ToList().ForEach(r => r.AddTags("JDBC")); // styles.Add(new RelationshipStyle("HTTPS") { Color = "#ff0000" }); // styles.Add(new RelationshipStyle("JDBC") { Color = "#0000ff" }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
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_CopyLayoutInformation_WhenAnElementNameAndDescriptionAndIdHaveChangedAndDescriptionWasNull() { Workspace workspace1 = new Workspace("1", ""); SoftwareSystem softwareSystem1 = workspace1.Model.AddSoftwareSystem("Software System"); Container container1 = softwareSystem1.AddContainer("Container"); container1.Description = null; ContainerView view1 = workspace1.Views.CreateContainerView(softwareSystem1, "key", ""); view1.Add(container1); view1.GetElementView(container1).X = 123; view1.GetElementView(container1).Y = 456; Workspace workspace2 = new Workspace("2", ""); SoftwareSystem softwareSystem2 = workspace2.Model.AddSoftwareSystem("Software System"); softwareSystem2.AddContainer("Web Application", "Description", ""); // this element has ID 2 Container container2 = softwareSystem2.AddContainer("Database", "Description", ""); ContainerView view2 = workspace2.Views.CreateContainerView(softwareSystem2, "key", ""); view2.Add(container2); DefaultLayoutMergeStrategy strategy = new DefaultLayoutMergeStrategy(); strategy.CopyLayoutInformation(view1, view2); Assert.Equal(0, view2.GetElementView(container2).X); Assert.Equal(0, view2.GetElementView(container2).Y); }
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); }
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); }
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); } }
public StructurizrDocumentationTests() { _softwareSystem = Model.AddSoftwareSystem("Name", "Description"); _containerA = _softwareSystem.AddContainer("Container A", "Description", "Technology"); _containerB = _softwareSystem.AddContainer("Container B", "Description", "Technology"); _componentA1 = _containerA.AddComponent("Component A1", "Description", "Technology"); _componentA2 = _containerA.AddComponent("Component A2", "Description", "Technology"); _template = new StructurizrDocumentationTemplate(Workspace); }
private void PopulateWorkspace() { Model model = _workspace.Model; model.Enterprise = new Enterprise("Some Enterprise"); Person user = model.AddPerson(Location.Internal, "User", ""); SoftwareSystem softwareSystem = model.AddSoftwareSystem(Location.Internal, "Software System", ""); user.Uses(softwareSystem, "Uses"); SoftwareSystem emailSystem = model.AddSoftwareSystem(Location.External, "E-mail System", ""); softwareSystem.Uses(emailSystem, "Sends e-mail using"); emailSystem.Delivers(user, "Delivers e-mails to"); Container webApplication = softwareSystem.AddContainer("Web Application", "", ""); Container database = softwareSystem.AddContainer("Database", "", ""); user.Uses(webApplication, "Uses", "HTTP"); webApplication.Uses(database, "Reads from and writes to", "JDBC"); webApplication.Uses(emailSystem, "Sends e-mail using"); Component controller = webApplication.AddComponent("SomeController", "", "Spring MVC Controller"); Component emailComponent = webApplication.AddComponent("EmailComponent", ""); Component repository = webApplication.AddComponent("SomeRepository", "", "Spring Data"); user.Uses(controller, "Uses", "HTTP"); controller.Uses(repository, "Uses"); controller.Uses(emailComponent, "Sends e-mail using"); repository.Uses(database, "Reads from and writes to", "JDBC"); emailComponent.Uses(emailSystem, "Sends e-mails using", "SMTP"); EnterpriseContextView enterpriseContextView = _workspace.Views.CreateEnterpriseContextView("enterpriseContext", ""); enterpriseContextView.AddAllElements(); SystemContextView systemContextView = _workspace.Views.CreateSystemContextView(softwareSystem, "systemContext", ""); systemContextView.AddAllElements(); ContainerView containerView = _workspace.Views.CreateContainerView(softwareSystem, "containers", ""); containerView.AddAllElements(); ComponentView componentView = _workspace.Views.CreateComponentView(webApplication, "components", ""); componentView.AddAllElements(); DynamicView dynamicView = _workspace.Views.CreateDynamicView(webApplication, "dynamic", ""); dynamicView.Add(user, "Requests /something", controller); dynamicView.Add(controller, repository); dynamicView.Add(repository, "select * from something", database); }
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"); // a direction could be added to relation (active in all views) // userUsesSystemRelation.SetDirection(DirectionValues.Right); ViewSet views = workspace.Views; SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); // C4PlantUMLWriter support view specific directions too, e.g. "User" should be left of "Software System" only in this view contextView.Relationships .First(rv => rv.Relationship.SourceId == user.Id && rv.Relationship.DestinationId == softwareSystem.Id) .SetDirection(DirectionValues.Right); using (var stringWriter = new StringWriter()) { var plantUmlWriter = new C4PlantUmlWriter(); plantUmlWriter.Write(workspace, stringWriter); Console.WriteLine(stringWriter.ToString()); } Container webApplication = softwareSystem.AddContainer("Web Application", "Delivers content", "Java and spring MVC"); Container database = softwareSystem.AddContainer("Database", "Stores information", "Relational Database Schema"); // Additional mark it as database database.SetIsDatabase(true); user.Uses(webApplication, "uses", "HTTP"); webApplication.Uses(database, "Reads from and writes to", "JDBC").SetDirection(DirectionValues.Right); var containerView = views.CreateContainerView(softwareSystem, "containers", ""); containerView.AddAllElements(); using (var stringWriter = new StringWriter()) { var plantUmlWriter = new C4PlantUmlWriter(); plantUmlWriter.Write(containerView, stringWriter); Console.WriteLine(stringWriter.ToString()); } }
public void Test_AddNearestNeighbours_AddsNearestNeighbours_WhenThereAreSomeNearestNeighbours() { SoftwareSystem softwareSystemA = model.AddSoftwareSystem("System A", "Description"); SoftwareSystem softwareSystemB = model.AddSoftwareSystem("System B", "Description"); Person userA = model.AddPerson("User A", "Description"); Person userB = model.AddPerson("User B", "Description"); // userA -> systemA -> system -> systemB -> userB userA.Uses(softwareSystemA, ""); softwareSystemA.Uses(softwareSystem, ""); softwareSystem.Uses(softwareSystemB, ""); softwareSystemB.Delivers(userB, ""); // userA -> systemA -> web application -> systemB -> userB // web application -> database Container webApplication = softwareSystem.AddContainer("Web Application", "", ""); Container database = softwareSystem.AddContainer("Database", "", ""); softwareSystemA.Uses(webApplication, ""); webApplication.Uses(softwareSystemB, ""); webApplication.Uses(database, ""); // userA -> systemA -> controller -> service -> repository -> database Component controller = webApplication.AddComponent("Controller", ""); Component service = webApplication.AddComponent("Service", ""); Component repository = webApplication.AddComponent("Repository", ""); softwareSystemA.Uses(controller, ""); controller.Uses(service, ""); service.Uses(repository, ""); repository.Uses(database, ""); // userA -> systemA -> controller -> service -> systemB -> userB service.Uses(softwareSystemB, ""); view.AddNearestNeighbours(softwareSystem); Assert.AreEqual(3, view.Elements.Count); Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystemA))); Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystem))); Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystemB))); view = new SystemContextView(softwareSystem, "context", "Description"); view.AddNearestNeighbours(softwareSystemA); Assert.AreEqual(3, view.Elements.Count); Assert.IsTrue(view.Elements.Contains(new ElementView(userA))); Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystemA))); Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystem))); }
public DynamicViewTests() { person = Model.AddPerson("Person", ""); softwareSystemA = Model.AddSoftwareSystem("Software System A", ""); containerA1 = softwareSystemA.AddContainer("Container A1", "", ""); componentA1 = containerA1.AddComponent("Component A1", ""); containerA2 = softwareSystemA.AddContainer("Container A2", "", ""); componentA2 = containerA2.AddComponent("Component A2", ""); containerA3 = softwareSystemA.AddContainer("Container A3", "", ""); relationship = containerA1.Uses(containerA2, "uses"); softwareSystemB = Model.AddSoftwareSystem("Software System B", ""); containerB1 = softwareSystemB.AddContainer("Container B1", "", ""); }
protected ContainerBase(SoftwareSystem softwareSystem, Structurizr.Styles styleContainer, Action <ElementType, string> onCreatedFromExistingElement) : base(styleContainer, onCreatedFromExistingElement) { if (!TryGetMetadata(out string description, out string technology)) { throw new System.Exception($"Missing ContainerAttribute on Container class {GetType().Name}"); } SoftwareSystem = softwareSystem; StyleContainer = styleContainer; _onCreatedFromExistingElement = onCreatedFromExistingElement; Components = new ComponentBase[0]; Styles = new ElementStyleBase[0]; var name = NamedIdentity.GetNameFromType(GetType()); var container = softwareSystem.GetContainerWithName(name); if (container == null) { container = softwareSystem.AddContainer(name, description, technology); } else { _onCreatedFromExistingElement(ElementType.Element, container.Id); container.Description = description; container.Technology = technology; } Element = Me = container; }
public void Test_AddDefaultElements() { Model.ImpliedRelationshipsStrategy = new CreateImpliedRelationshipsUnlessAnyRelationshipExistsStrategy(); Person user1 = Model.AddPerson("User 1"); Person user2 = Model.AddPerson("User 2"); SoftwareSystem softwareSystem1 = Model.AddSoftwareSystem("Software System 1"); Container container1 = softwareSystem1.AddContainer("Container 1", "", ""); Component component1 = container1.AddComponent("Component 1", "", ""); SoftwareSystem softwareSystem2 = Model.AddSoftwareSystem("Software System 2"); Container container2 = softwareSystem2.AddContainer("Container 2", "", ""); Component component2 = container2.AddComponent("Component 2", "", ""); user1.Uses(component1, "Uses"); user2.Uses(component2, "Uses"); component1.Uses(component2, "Uses"); view = new ComponentView(container1, "components", "Description"); view.AddDefaultElements(); Assert.Equal(3, view.Elements.Count); Assert.True(view.Elements.Contains(new ElementView(user1))); Assert.False(view.Elements.Contains(new ElementView(user2))); Assert.False(view.Elements.Contains(new ElementView(softwareSystem1))); Assert.True(view.Elements.Contains(new ElementView(softwareSystem2))); Assert.False(view.Elements.Contains(new ElementView(container1))); Assert.False(view.Elements.Contains(new ElementView(container2))); Assert.True(view.Elements.Contains(new ElementView(component1))); Assert.False(view.Elements.Contains(new ElementView(component2))); }
public void Test_CopyLayoutInformation_WhenAnElementNameAndDescriptionHaveChangedButTheIdHasNotChanged() { Workspace workspace1 = new Workspace("1", ""); SoftwareSystem softwareSystem1 = workspace1.Model.AddSoftwareSystem("Software System"); Container container1 = softwareSystem1.AddContainer("Container", "Container description", ""); ContainerView view1 = workspace1.Views.CreateContainerView(softwareSystem1, "key", ""); view1.Add(container1); view1.GetElementView(container1).X = 123; view1.GetElementView(container1).Y = 456; Workspace workspace2 = new Workspace("2", ""); SoftwareSystem softwareSystem2 = workspace2.Model.AddSoftwareSystem("Software System"); Container container2 = softwareSystem2.AddContainer("Container with a new name", "Container with a new description", ""); ContainerView view2 = workspace2.Views.CreateContainerView(softwareSystem2, "key", ""); view2.Add(container2); DefaultLayoutMergeStrategy strategy = new DefaultLayoutMergeStrategy(); strategy.CopyLayoutInformation(view1, view2); Assert.Equal(123, view2.GetElementView(container2).X); Assert.Equal(456, view2.GetElementView(container2).Y); }
public ComponentTests() { workspace = new Workspace("Name", "Description"); model = workspace.Model; softwareSystem = model.AddSoftwareSystem("System", "Description"); container = softwareSystem.AddContainer("Container", "Description", "Some technology"); }
public void Test_Add_DoesNothing_WhenTheSpecifiedComponentIsInADifferentContainer() { SoftwareSystem softwareSystemA = Model.AddSoftwareSystem("System A", "Description"); Container containerA1 = softwareSystemA.AddContainer("Container A1", "Description", "Tec"); Component componentA1_1 = containerA1.AddComponent("Component A1-1", "Description"); Container containerA2 = softwareSystemA.AddContainer("Container A2", "Description", "Tec"); Component componentA2_1 = containerA2.AddComponent("Component A2-1", "Description"); view = new ComponentView(containerA1, "components", "Description"); view.Add(componentA1_1); view.Add(componentA2_1); Assert.Equal(1, view.Elements.Count); Assert.True(view.Elements.Contains(new ElementView(componentA1_1))); }
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(); }
public DocumentationTests() { Workspace workspace = new Workspace("Name", "Description"); Model model = workspace.Model; softwareSystem = model.AddSoftwareSystem("Name", "Description"); container = softwareSystem.AddContainer("Name", "Description", "Technology"); documentation = workspace.Documentation; }
internal C4Builder AddContainer(string containerName, string containerDescription, string containerTechnology, string tag = null) { var container = _currentSoftwareSystem.AddContainer(containerName, containerDescription, containerTechnology); if (!string.IsNullOrEmpty(tag)) { container.AddTags(tag); } return(this); }
public void Test_ElementWithCanonicalName_ReturnsTheElement_WhenAnElementWithTheSpecifiedCanonicalNameExists() { SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "Description"); Assert.Same(softwareSystem, Model.GetElementWithCanonicalName("SoftwareSystem://Software System")); Container container = softwareSystem.AddContainer("Web Application", "Description", "Technology"); Assert.Same(container, Model.GetElementWithCanonicalName("Container://Software System.Web Application")); }
public void test_impliedRelationships_WhenNoSummaryRelationshipsExist() { SoftwareSystem a = Model.AddSoftwareSystem("A", ""); Container aa = a.AddContainer("AA", "", ""); Component aaa = aa.AddComponent("AAA", "", ""); SoftwareSystem b = Model.AddSoftwareSystem("B", ""); Container bb = b.AddContainer("BB", "", ""); Component bbb = bb.AddComponent("BBB", "", ""); Model.ImpliedRelationshipsStrategy = new CreateImpliedRelationshipsUnlessSameRelationshipExistsStrategy(); aaa.Uses(bbb, "Uses 1", null, InteractionStyle.Asynchronous, new String[] { "Tag 1", "Tag 2" }); Assert.Equal(9, Model.Relationships.Count); Assert.True(aaa.HasEfferentRelationshipWith(bbb, "Uses 1")); // and all relationships should have the same interaction style and tags foreach (Relationship r in Model.Relationships) { Assert.Equal(InteractionStyle.Asynchronous, r.InteractionStyle); Assert.True(r.GetTagsAsSet().Contains("Tag 1")); Assert.True(r.GetTagsAsSet().Contains("Tag 2")); } // AAA->BBB implies AAA->BB AAA->B AA->BBB AA->BB AA->B A->BBB A->BB A->B Assert.True(aaa.HasEfferentRelationshipWith(bb, "Uses 1")); Assert.True(aaa.HasEfferentRelationshipWith(b, "Uses 1")); Assert.True(aa.HasEfferentRelationshipWith(bbb, "Uses 1")); Assert.True(aa.HasEfferentRelationshipWith(bb, "Uses 1")); Assert.True(aa.HasEfferentRelationshipWith(b, "Uses 1")); Assert.True(a.HasEfferentRelationshipWith(bbb, "Uses 1")); Assert.True(a.HasEfferentRelationshipWith(bb, "Uses 1")); Assert.True(a.HasEfferentRelationshipWith(b, "Uses 1")); // and add another relationship with a different description aaa.Uses(bbb, "Uses 2"); Assert.Equal(18, Model.Relationships.Count); Assert.True(aaa.HasEfferentRelationshipWith(bbb, "Uses 2")); // AAA->BBB implies AAA->BB AAA->B AA->BBB AA->BB AA->B A->BBB A->BB A->B Assert.True(aaa.HasEfferentRelationshipWith(bb, "Uses 2")); Assert.True(aaa.HasEfferentRelationshipWith(b, "Uses 2")); Assert.True(aa.HasEfferentRelationshipWith(bbb, "Uses 2")); Assert.True(aa.HasEfferentRelationshipWith(bb, "Uses 2")); Assert.True(aa.HasEfferentRelationshipWith(b, "Uses 2")); Assert.True(a.HasEfferentRelationshipWith(bbb, "Uses 2")); Assert.True(a.HasEfferentRelationshipWith(bb, "Uses 2")); Assert.True(a.HasEfferentRelationshipWith(b, "Uses 2")); }
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)); }
private static Container CreateContainerApi(SoftwareSystem publicServiceRegistry) { var api = publicServiceRegistry .AddContainer( "Loket API", "Publiek beschikbare API, bedoeld ter integratie in het loket.", "REST/HTTPS"); api.Id = ContainerApiId; return(api); }
private static Container CreateContainerApiRunner(SoftwareSystem publicServiceRegistry) { var apiRunner = publicServiceRegistry .AddContainer( "Loket API projecties", "Asynchrone runner die events verwerkt ten behoeve van de loket API.", "Event Sourcing"); apiRunner.Id = ContainerApiRunnerId; return(apiRunner); }
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); }
public void Test_NormalSequence() { Workspace = new Workspace("Name", "Description"); Model = Workspace.Model; SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "Description"); Container container1 = softwareSystem.AddContainer("Container 1", "Description", "Technology"); Container container2 = softwareSystem.AddContainer("Container 2", "Description", "Technology"); Container container3 = softwareSystem.AddContainer("Container 3", "Description", "Technology"); container1.Uses(container2, "Uses"); container1.Uses(container3, "Uses"); DynamicView view = Workspace.Views.CreateDynamicView(softwareSystem, "key", "Description"); view.Add(container1, container2); view.Add(container1, container3); Assert.Same(container2, view.Relationships.First(rv => rv.Order.Equals("1")).Relationship.Destination); Assert.Same(container3, view.Relationships.First(rv => rv.Order.Equals("2")).Relationship.Destination); }
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); }
public void test_uses_AddsARelationship_WhenADestinationIsSpecified() { Container database = _softwareSystem.AddContainer("Database", "", ""); ContainerInstance primaryDatabase = Model.AddContainerInstance(database); ContainerInstance secondaryDatabase = Model.AddContainerInstance(database); Relationship relationship = primaryDatabase.Uses(secondaryDatabase, "Replicates data to", "Some technology"); Assert.Same(primaryDatabase, relationship.Source); Assert.Same(secondaryDatabase, relationship.Destination); Assert.Equal("Replicates data to", relationship.Description); Assert.Equal("Some technology", relationship.Technology); }
private static Container CreateContainerApiStore(SoftwareSystem publicServiceRegistry) { var apiStore = publicServiceRegistry .AddContainer( "Loket API gegevens", "Gegevens geoptimaliseerd voor de loket API.", "SQL Server"); apiStore.Id = ContainerApiStoreId; apiStore.AddTags(CustomTags.Store); return(apiStore); }
private static Container CreateContainerAggregateRoot(SoftwareSystem publicServiceRegistry) { var aggregateRoot = publicServiceRegistry .AddContainer( "AggregateRoot", "Authentieke objecten.", ".NET Core/C#"); aggregateRoot.Id = ContainerAggregateRootId; aggregateRoot.AddTags(CustomTags.Store); return(aggregateRoot); }