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));
        }
示例#2
0
        public void Test_AddRelationship_DisallowsTheSameRelationshipToBeAddedMoreThanOnce()
        {
            SoftwareSystem element1      = Model.AddSoftwareSystem("Element 1", "Description");
            SoftwareSystem element2      = Model.AddSoftwareSystem("Element 2", "Description");
            Relationship   relationship1 = element1.Uses(element2, "Uses", "");
            Relationship   relationship2 = element1.Uses(element2, "Uses", "");

            Assert.True(element1.Has(relationship1));
            Assert.Null(relationship2);
            Assert.Equal(1, element1.Relationships.Count);
        }
示例#3
0
        public void Test_AddAllSoftwareSystems_AddsAllSoftwareSystems_WhenThereAreSomeSoftwareSystemsInTheModel()
        {
            SoftwareSystem softwareSystemA = Model.AddSoftwareSystem(Location.External, "System A", "Description");
            SoftwareSystem softwareSystemB = Model.AddSoftwareSystem(Location.External, "System B", "Description");

            view.AddAllSoftwareSystems();

            Assert.Equal(2, view.Elements.Count);
            Assert.True(view.Elements.Contains(new ElementView(softwareSystemA)));
            Assert.True(view.Elements.Contains(new ElementView(softwareSystemB)));
        }
示例#4
0
        public void Test_AddAllElements_AddsAllSoftwareSystemsAndPeople_WhenThereAreSomeSoftwareSystemsAndPeopleInTheModel()
        {
            SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "Description");
            Person         person         = model.AddPerson("Person", "Description");

            view.AddAllElements();

            Assert.AreEqual(2, view.Elements.Count);
            Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystem)));
            Assert.IsTrue(view.Elements.Contains(new ElementView(person)));
        }
示例#5
0
        public void Test_AddRelationship_AllowsMultipleRelationshipsBetweenElements()
        {
            SoftwareSystem element1      = Model.AddSoftwareSystem("Element 1", "Description");
            SoftwareSystem element2      = Model.AddSoftwareSystem("Element 2", "Description");
            Relationship   relationship1 = element1.Uses(element2, "Uses in some way", "");
            Relationship   relationship2 = element1.Uses(element2, "Uses in another way", "");

            Assert.True(element1.Has(relationship1));
            Assert.True(element1.Has(relationship2));
            Assert.Equal(2, element1.Relationships.Count);
        }
示例#6
0
 private string CalculateUrl(SoftwareSystem softwareSystem, string id)
 {
     if (softwareSystem == null)
     {
         return("#/:" + UrlEncode(id));
     }
     else
     {
         return("#" + UrlEncode(softwareSystem.CanonicalName) + ":" + UrlEncode(id));
     }
 }
示例#7
0
        public void Test_AddSoftwareSystem_ThrowsAnException_WhenTheSoftwareSystemIsTheScopeOfTheView()
        {
            SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System");

            view = new ContainerView(softwareSystem, "containers", "Description");
            try {
                view.Add(softwareSystem);
                throw new TestFailedException();
            } catch (ElementNotPermittedInViewException e) {
                Assert.Equal("The software system in scope cannot be added to a container view.", e.Message);
            }
        }
示例#8
0
        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, "TagA", "TagB"
            }, relation.GetAllTags());
        }
示例#9
0
        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);
        }
示例#10
0
        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);
        }
示例#11
0
        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);
        }
示例#12
0
        public void Test_GetEfferentRelationshipWith_ReturnsCyclicRelationship_WhenTheSameElementIsSpecifiedAndACyclicRelationshipExists()
        {
            SoftwareSystem softwareSystem1 = Model.AddSoftwareSystem("System 1", "");

            softwareSystem1.Uses(softwareSystem1, "uses");

            Relationship relationship = softwareSystem1.GetEfferentRelationshipWith(softwareSystem1);

            Assert.Same(softwareSystem1, relationship.Source);
            Assert.Equal("uses", relationship.Description);
            Assert.Same(softwareSystem1, relationship.Destination);
        }
        private static void CreateContextView(ViewSet views, SoftwareSystem baseRegistries)
        {
            var contextView = views
                              .CreateSystemContextView(
                baseRegistries,
                "Globaal overzicht",
                "Globaal overzicht van Basisregisters Vlaanderen.");

            contextView.Add(baseRegistries);

            contextView.PaperSize = PaperSize.A6_Portrait;
        }
示例#14
0
        public void Test_ElementWithCanonicalName_ReturnsTheElement_WhenAnElementWithTheSpecifiedCanonicalNameExists()
        {
            SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "Description");

            Assert.Same(Model.GetElementWithCanonicalName("/Software System"), softwareSystem);
            Assert.Same(Model.GetElementWithCanonicalName("Software System"), softwareSystem);

            Container container = softwareSystem.AddContainer("Web Application", "Description", "Technology");

            Assert.Same(container, Model.GetElementWithCanonicalName("/Software System/Web Application"));
            Assert.Same(container, Model.GetElementWithCanonicalName("Software System/Web Application"));
        }
示例#15
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);
        }
示例#16
0
        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);
        }
        public void test_addSection()
        {
            SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "Description");
            Section        section        = _documentation.AddSection(softwareSystem, "Title", Format.Markdown, "Content");

            Assert.Equal(1, _documentation.Sections.Count);
            Assert.True(_documentation.Sections.Contains(section));
            Assert.Same(softwareSystem, section.Element);
            Assert.Equal("Title", section.Title);
            Assert.Equal(Format.Markdown, section.Format);
            Assert.Equal("Content", section.Content);
            Assert.Equal(1, section.Order);
        }
 public void test_addSection_ThrowsAnException_WhenTheRelatedElementIsNotPresentInTheAssociatedModel()
 {
     try
     {
         SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "Description");
         new Workspace("", "").Documentation.AddSection(softwareSystem, "Title", Format.Markdown, "Content");
         throw new TestFailedException();
     }
     catch (ArgumentException iae)
     {
         Assert.Equal("The element named Software System does not exist in the model associated with this documentation.", iae.Message);
     }
 }
示例#19
0
        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);
        }
示例#20
0
        public void Test_GetEfferentRelationshipWith_ReturnsTheRelationship_WhenThereIsARelationship()
        {
            SoftwareSystem softwareSystem1 = Model.AddSoftwareSystem("System 1", "");
            SoftwareSystem softwareSystem2 = Model.AddSoftwareSystem("System 2", "");

            softwareSystem1.Uses(softwareSystem2, "uses");

            Relationship relationship = softwareSystem1.GetEfferentRelationshipWith(softwareSystem2);

            Assert.Same(softwareSystem1, relationship.Source);
            Assert.Equal("uses", relationship.Description);
            Assert.Same(softwareSystem2, relationship.Destination);
        }
示例#21
0
 public void Test_SetUrl_ThrowsAnException_WhenAnInvalidUrlIsSpecified()
 {
     try
     {
         SoftwareSystem element = Model.AddSoftwareSystem("Name", "Description");
         element.Url = "www.somedomain.com";
         throw new TestFailedException();
     }
     catch (Exception e)
     {
         Assert.Equal("www.somedomain.com is not a valid URL.", e.Message);
     }
 }
示例#22
0
        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)));
        }
示例#23
0
        private static Container CreateContainerEventStore(SoftwareSystem publicServiceRegistry)
        {
            var eventStore = publicServiceRegistry
                             .AddContainer(
                "Eventstore",
                "Authentieke bron van gegevens, opgeslagen als een stroom van events.",
                "SQL Server");

            eventStore.Id = ContainerEventStoreId;
            eventStore.AddTags(CustomTags.Store);

            return(eventStore);
        }
示例#24
0
        public void Test_AddDefaultElements()
        {
            Person         user            = Model.AddPerson("User");
            SoftwareSystem softwareSystem1 = Model.AddSoftwareSystem("Software System 1");
            SoftwareSystem softwareSystem2 = Model.AddSoftwareSystem("Software System 2");

            view.AddDefaultElements();

            Assert.Equal(3, view.Elements.Count);
            Assert.True(view.Elements.Contains(new ElementView(user)));
            Assert.True(view.Elements.Contains(new ElementView(softwareSystem1)));
            Assert.True(view.Elements.Contains(new ElementView(softwareSystem2)));
        }
示例#25
0
        public void Test_ParallelSequence()
        {
            Workspace = new Workspace("Name", "Description");
            Model     = Workspace.Model;
            SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Name", "Description");
            Person         user           = Model.AddPerson("User", "Description");
            Container      microservice1  = softwareSystem.AddContainer("Microservice 1", "", "");
            Container      database1      = softwareSystem.AddContainer("Database 1", "", "");
            Container      microservice2  = softwareSystem.AddContainer("Microservice 2", "", "");
            Container      database2      = softwareSystem.AddContainer("Database 2", "", "");
            Container      microservice3  = softwareSystem.AddContainer("Microservice 3", "", "");
            Container      database3      = softwareSystem.AddContainer("Database 3", "", "");
            Container      messageBus     = softwareSystem.AddContainer("Message Bus", "", "");

            user.Uses(microservice1, "Updates using");
            microservice1.Delivers(user, "Sends updates to");

            microservice1.Uses(database1, "Stores data in");
            microservice1.Uses(messageBus, "Sends messages to");
            microservice1.Uses(messageBus, "Sends messages to");

            messageBus.Uses(microservice2, "Sends messages to");
            messageBus.Uses(microservice3, "Sends messages to");

            microservice2.Uses(database2, "Stores data in");
            microservice3.Uses(database3, "Stores data in");

            DynamicView view = Workspace.Views.CreateDynamicView(softwareSystem, "key", "Description");

            view.Add(user, "1", microservice1);
            view.Add(microservice1, "2", database1);
            view.Add(microservice1, "3", messageBus);

            view.StartParallelSequence();
            view.Add(messageBus, "4", microservice2);
            view.Add(microservice2, "5", database2);
            view.EndParallelSequence();

            view.StartParallelSequence();
            view.Add(messageBus, "4", microservice3);
            view.Add(microservice3, "5", database3);
            view.EndParallelSequence();

            view.Add(microservice1, "5", database1);

            Assert.Equal(1, view.Relationships.Count(r => r.Order.Equals("1")));
            Assert.Equal(1, view.Relationships.Count(r => r.Order.Equals("2")));
            Assert.Equal(1, view.Relationships.Count(r => r.Order.Equals("3")));
            Assert.Equal(3, view.Relationships.Count(r => r.Order.Equals("4")));
            Assert.Equal(2, view.Relationships.Count(r => r.Order.Equals("5")));
        }
示例#26
0
        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_addSection_ThrowsAnException_WhenASectionExistsWithTheSameTitleForAnElement()
 {
     try
     {
         SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "Description");
         _documentation.AddSection(softwareSystem, "Title", Format.Markdown, "Content");
         _documentation.AddSection(softwareSystem, "Title", Format.Markdown, "Content");
         throw new TestFailedException();
     }
     catch (ArgumentException iae)
     {
         Assert.Equal("A section with a title of Title already exists for the element named Software System.", iae.Message);
     }
 }
        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", "", "");
        }
 public void test_addDecision_ThrowsAnException_WhenADecisionExistsWithTheSameIdForAnElement()
 {
     try
     {
         SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", "Description");
         _documentation.AddDecision(softwareSystem, "1", new DateTime(), "Title", DecisionStatus.Accepted, Format.Markdown, "Content");
         _documentation.AddDecision(softwareSystem, "1", new DateTime(), "Title", DecisionStatus.Accepted, Format.Markdown, "Content");
         throw new TestFailedException();
     }
     catch (ArgumentException iae)
     {
         Assert.Equal("A decision with an ID of 1 already exists for the element named Software System.", iae.Message);
     }
 }
示例#30
0
        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 KnownSystemLogic( SoftwareSystem rsisSystem )
 {
     this.rsisSystem = rsisSystem;
 }