Ejemplo n.º 1
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 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 = new ComponentView(webApplication, "components", "Description");
            view.AddNearestNeighbours(softwareSystemA);

            Assert.Equal(3, view.Elements.Count);
            Assert.True(view.Elements.Contains(new ElementView(userA)));
            Assert.True(view.Elements.Contains(new ElementView(softwareSystemA)));
            Assert.True(view.Elements.Contains(new ElementView(controller)));

            view = new ComponentView(webApplication, "components", "Description");
            view.AddNearestNeighbours(controller);

            Assert.Equal(3, view.Elements.Count);
            Assert.True(view.Elements.Contains(new ElementView(softwareSystemA)));
            Assert.True(view.Elements.Contains(new ElementView(controller)));
            Assert.True(view.Elements.Contains(new ElementView(service)));

            view = new ComponentView(webApplication, "components", "Description");
            view.AddNearestNeighbours(service);

            Assert.Equal(4, view.Elements.Count);
            Assert.True(view.Elements.Contains(new ElementView(controller)));
            Assert.True(view.Elements.Contains(new ElementView(service)));
            Assert.True(view.Elements.Contains(new ElementView(repository)));
            Assert.True(view.Elements.Contains(new ElementView(softwareSystemB)));
        }
Ejemplo n.º 2
0
        public void Test_AddNearestNeightbours_DoesNothing_WhenANullElementIsSpecified()
        {
            view.AddNearestNeighbours(null);

            Assert.Equal(0, view.Elements.Count);
        }