Ejemplo n.º 1
0
        private static void Main()
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
                                .AddJsonFile($"appsettings.{Environment.MachineName.ToLowerInvariant()}.json", optional: true, reloadOnChange: false)
                                .Build();

            var workspaceId = long.Parse(configuration["Structurizr:WorkspaceId"]);
            var apiKey      = configuration["Structurizr:ApiKey"];
            var apiSecret   = configuration["Structurizr:ApiSecret"];
            var adrPath     = configuration["Structurizr:AdrPath"];

            var workspace = new Workspace("Dns", "Voorbeeld register.")
            {
                Version = DateTime.Today.ToString("yyyy-MM-dd"),
            };

            var model = workspace.Model;

            var user = CreatePersonUser(model);

            var dns = CreateSystemDns(model);

            var api        = CreateContainerApi(dns);
            var apiRunner  = CreateContainerApiRunner(dns);
            var apiStore   = CreateContainerApiStore(dns);
            var eventStore = CreateContainerEventStore(dns);

            user.Uses(dns, "raadpleegt", "HTTPS").AddTags(CustomTags.Https);
            user.Uses(api, "raadpleegt", "HTTPS").AddTags(CustomTags.Https);

            api.Uses(apiStore, "leest gegevens", "Entity Framework").AddTags(CustomTags.EntityFramework);
            api.Uses(eventStore, "produceert events", "SqlStreamStore").AddTags(CustomTags.SqlStreamStore);

            apiRunner.Uses(eventStore, "leest events", "SqlStreamStore").AddTags(CustomTags.SqlStreamStore);
            apiRunner.Uses(apiStore, "projecteert gegevens", "Entity Framework").AddTags(CustomTags.EntityFramework);

            CreateApiFake(model);
            //CreateApiRunnerFake(model);

            var views = workspace.Views;

            CreateContextView(views, model);
            CreateApiContainerView(views, model);
            CreateApiRunnerContainerView(views, model);

            ConfigureStyles(views);

            var adrDirectory     = new DirectoryInfo(adrPath);
            var adrToolsImporter = new AdrToolsImporter(workspace, adrDirectory);

            adrToolsImporter.ImportArchitectureDecisionRecords(dns);

            UploadWorkspaceToStructurizr(workspace, workspaceId, apiKey, apiSecret);
        }
Ejemplo n.º 2
0
        public void Test_TmportArchitectureDecisionRecords_RewritesLinksBetweenADRsWhenTheyAreAssociatedWithAnElement()
        {
            AdrToolsImporter importer = new AdrToolsImporter(_workspace, new DirectoryInfo("AdrTools\\adrs"));

            importer.ImportArchitectureDecisionRecords(_softwareSystem);

            Decision decision5 = _documentation.Decisions.Where(d => d.Id == "5").First();

            Assert.True(decision5.Content.Contains("Amended by [9. Help scripts](#%2FSoftware%20System:9)"));
        }
Ejemplo n.º 3
0
        public void Test_ImportArchitectureDecisionRecords_SupportsTheIncorrectSpellingOfSuperseded()
        {
            AdrToolsImporter importer = new AdrToolsImporter(_workspace, new DirectoryInfo("AdrTools\\adrs"));

            importer.ImportArchitectureDecisionRecords();

            Decision decision4 = _documentation.Decisions.Where(d => d.Id == "4").First();

            Assert.Equal(DecisionStatus.Superseded, decision4.Status);
            Assert.True(decision4.Content.Contains("Superceded by [10. AsciiDoc format](#/:10)"));
        }
Ejemplo n.º 4
0
        public void Test_ImportArchitectureDecisionRecords()
        {
            AdrToolsImporter importer = new AdrToolsImporter(_workspace, new DirectoryInfo("AdrTools\\adrs"));

            importer.ImportArchitectureDecisionRecords();

            Assert.Equal(10, _documentation.Decisions.Count);

            Decision decision1 = _documentation.Decisions.Where(d => d.Id == "1").First();

            Assert.Equal("1", decision1.Id);
            Assert.Equal("Record architecture decisions", decision1.Title);
            Assert.Equal("12/02/2016 00:00:00", decision1.Date.ToString());
            Assert.Equal(DecisionStatus.Accepted, decision1.Status);
            Assert.Equal(Format.Markdown, decision1.Format);
            Assert.Equal("# 1. Record architecture decisions\n" +
                         "\n" +
                         "Date: 2016-02-12\n" +
                         "\n" +
                         "## Status\n" +
                         "\n" +
                         "Accepted\n" +
                         "\n" +
                         "## Context\n" +
                         "\n" +
                         "We need to record the architectural decisions made on this project.\n" +
                         "\n" +
                         "## Decision\n" +
                         "\n" +
                         "We will use Architecture Decision Records, as described by Michael Nygard in this article: http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions\n" +
                         "\n" +
                         "## Consequences\n" +
                         "\n" +
                         "See Michael Nygard's article, linked above.\n",
                         decision1.Content);
        }
Ejemplo n.º 5
0
        static void Main()
        {
            Workspace workspace = new Workspace("adr-tools", "A description of the adr-tools command line utility.");
            Model     model     = workspace.Model;

            Person         user     = model.AddPerson("User", "Somebody on a software development team.");
            SoftwareSystem adrTools = model.AddSoftwareSystem("adr-tools", "A command-line tool for working with Architecture Decision Records (ADRs).");

            adrTools.Url = "https://github.com/npryce/adr-tools";

            Container adrShellScripts = adrTools.AddContainer("adr", "A command-line tool for working with Architecture Decision Records (ADRs).", "Shell Scripts");

            adrShellScripts.Url = "https://github.com/npryce/adr-tools/tree/master/src";
            Container fileSystem = adrTools.AddContainer("File System", "Stores ADRs, templates, etc.", "File System");

            fileSystem.AddTags(FileSystemTag);
            user.Uses(adrShellScripts, "Manages ADRs using");
            adrShellScripts.Uses(fileSystem, "Reads from and writes to");
            model.AddImplicitRelationships();

            ViewSet           views       = workspace.Views;
            SystemContextView contextView = views.CreateSystemContextView(adrTools, "SystemContext", "The system context diagram for adr-tools.");

            contextView.AddAllElements();

            ContainerView containerView = views.CreateContainerView(adrTools, "Containers", "The container diagram for adr-tools.");

            containerView.AddAllElements();

            DirectoryInfo adrDirectory = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "adr");

            AdrToolsImporter adrToolsImporter = new AdrToolsImporter(workspace, adrDirectory);

            adrToolsImporter.ImportArchitectureDecisionRecords(adrTools);

            Styles styles = views.Configuration.Styles;

            styles.Add(new ElementStyle(Tags.Element)
            {
                Shape = Shape.RoundedBox, Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.SoftwareSystem)
            {
                Background = "#18ADAD", Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.Person)
            {
                Shape = Shape.Person, Background = "#008282", Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.Container)
            {
                Background = "#6DBFBF"
            });
            styles.Add(new ElementStyle(FileSystemTag)
            {
                Shape = Shape.Folder
            });

            StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret);

            structurizrClient.PutWorkspace(WorkspaceId, workspace);
        }