Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions C4InterFlow.Automation/CsvDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ public record Container
[Index(5)]
public string Description { get; set; }

[Name("Boundary")]
[Index(6)]
public string Boundary { get; set; }

[Name("Technology")]
[Index(7)]
public string Technology { get; set; }


public IEnumerable<ContainerAttribute> WithAttributes(CsvDataProvider dataProvider)
{
return dataProvider.ContainerAttributeRecords.Where(x => !string.IsNullOrEmpty(x.Container.Trim()) &&
Expand Down Expand Up @@ -488,6 +497,10 @@ public record Actor
[Name("Alias")]
[Index(3)]
public string Alias { get; set; }

[Name("Description")]
[Index(4)]
public string Description { get; set; }
public bool TryGetType(CsvDataProvider dataProvider, out string? type)
{
type = dataProvider.ActorTypeRecords.FirstOrDefault(x => x.Name == TypeName)?.Type;
Expand Down
2 changes: 1 addition & 1 deletion C4InterFlow.Automation/Writers/CsvToAnyAaCWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected CsvToAnyAaCWriter(string architectureInputPath)
{
ArchitectureInputPath = architectureInputPath;

Log.Information("Reading data from {Path}", ArchitectureInputPath);
Log.Information("Reading CSV data from '{Path}'", ArchitectureInputPath);

DataProvider = new CsvDataProvider(ArchitectureInputPath);
}
Expand Down
24 changes: 22 additions & 2 deletions C4InterFlow.Automation/Writers/CsvToJObjectAaCWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ public CsvToJObjectAaCWriter WithBusinessProcessesCollection()
return DataProvider.BusinessProcessRecords.Where(x => !string.IsNullOrEmpty(x.Alias.Trim()));
}

public override CsvToJObjectAaCWriter AddActor(string name, string type, string? label = null)
public override CsvToJObjectAaCWriter AddActor(string name, string type, string? label = null) =>
AddActor(name, type, label, null);

public CsvToJObjectAaCWriter AddActor(string name, string type, string? label = null, string? description = null)
{
var actorsObject = JsonArchitectureAsCode.SelectToken($"{ArchitectureNamespace}.Actors") as JObject;

Expand All @@ -97,6 +100,10 @@ public override CsvToJObjectAaCWriter AddActor(string name, string type, string?
{ "Type", type },
{ "Label", string.IsNullOrEmpty(label) ? AnyCodeWriter.GetLabel(name) : label },
};
if (!string.IsNullOrWhiteSpace(description))
{
actorObject["Description"] = description;
}

actorsObject.Add(name, actorObject);
}
Expand Down Expand Up @@ -236,7 +243,10 @@ public override CsvToJObjectAaCWriter AddSoftwareSystemInterface(
return this;
}

public override CsvToJObjectAaCWriter AddContainer(string softwareSystemName, string name, string? containerType = null, string? label = null, string? description = null)
public override CsvToJObjectAaCWriter AddContainer(string softwareSystemName, string name,
string? containerType = null, string? label = null, string? description = null) =>
AddContainer(softwareSystemName, name, containerType, label, description, null, null);
public CsvToJObjectAaCWriter AddContainer(string softwareSystemName, string name, string? containerType = null, string? label = null, string? description = null, string? boundary = null, string? technology = null)
{
var containersObject = JsonArchitectureAsCode.SelectToken($"{ArchitectureNamespace}.SoftwareSystems.{softwareSystemName}.Containers") as JObject;
if (containersObject == null)
Expand All @@ -263,6 +273,16 @@ public override CsvToJObjectAaCWriter AddContainer(string softwareSystemName, st
containerObject.Add("Description", description);
}

if (!string.IsNullOrEmpty(boundary))
{
containerObject.Add("Boundary", boundary);
}

if (!string.IsNullOrEmpty(technology))
{
containerObject.Add("Technology", technology);
}

containersObject.Add(name, containerObject);
}

Expand Down
4 changes: 2 additions & 2 deletions C4InterFlow.Automation/Writers/CsvToYamlAaCGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Execute()
s.WithContainers(writer.DataProvider).ToList().ForEach(c =>
{
var containerName = c.Alias.Split('.').Last();
writer.AddContainer(softwareSystemName, containerName, c.Type, c.Name, c.Description);
writer.AddContainer(softwareSystemName, containerName, c.Type, c.Name, c.Description, c.Boundary, c.Technology);

c.WithInterfaces(writer.DataProvider).ToList().ForEach(i =>
{
Expand Down Expand Up @@ -66,7 +66,7 @@ public override void Execute()
type = nameof(Person);
}

writer.AddActor(a.Alias, type, a.Name);
writer.AddActor(a.Alias, type, a.Name, a.Description);

writer.WriteArchitecture(Path.Combine(ArchitectureOutputPath, "Actors"), a.Alias);
});
Expand Down
35 changes: 23 additions & 12 deletions C4InterFlow.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@

using System.CommandLine.Builder;
using System.CommandLine.Parsing;
using System.Runtime.CompilerServices;
using C4InterFlow.Cli.Commands;
using C4InterFlow.Cli.Extensions;
using C4InterFlow.Cli.Root;

var rootCommandBuilder = RootCommandBuilder
.CreateDefaultBuilder(args)
.Configure(context =>
[assembly:InternalsVisibleTo("C4InterFlow.Specs")]

namespace C4InterFlow.Cli;

internal class Program
{
public static async Task<int> Main(string[] args)
{
context.Add<DrawDiagramsCommand>();
context.Add<QueryUseFlowsCommand>();
context.Add<QueryByInputCommand>();
context.Add<ExecuteAaCStrategyCommand>();
context.Add<GenerateDocumentationCommand>();
context.Add<PublishSiteCommand>();
});
var rootCommandBuilder = RootCommandBuilder
.CreateDefaultBuilder(args)
.Configure(context =>
{
context.Add<DrawDiagramsCommand>();
context.Add<QueryUseFlowsCommand>();
context.Add<QueryByInputCommand>();
context.Add<ExecuteAaCStrategyCommand>();
context.Add<GenerateDocumentationCommand>();
context.Add<PublishSiteCommand>();
});

await new CommandLineBuilder(rootCommandBuilder.Build())
.UseDefaults().UseLogging().Build().InvokeAsync(args);
return await new CommandLineBuilder(rootCommandBuilder.Build())
.UseDefaults().UseLogging().Build().InvokeAsync(args);
}
}
14 changes: 10 additions & 4 deletions C4InterFlow.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C4Interflow.Specs", "C4Interflow.Specs\C4Interflow.Specs.csproj", "{F6E21C47-44DA-4569-AE39-6093C9222E03}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EB78BBEC-4D8A-456C-90F1-920E45FFF982}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB78BBEC-4D8A-456C-90F1-920E45FFF982}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB78BBEC-4D8A-456C-90F1-920E45FFF982}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB78BBEC-4D8A-456C-90F1-920E45FFF982}.Release|Any CPU.Build.0 = Release|Any CPU
{B047B5AE-FA9A-453E-B522-F53ED61A0C80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B047B5AE-FA9A-453E-B522-F53ED61A0C80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B047B5AE-FA9A-453E-B522-F53ED61A0C80}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -28,10 +34,10 @@ Global
{5DD6985D-35AC-4154-B09B-2186AB9AA3AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DD6985D-35AC-4154-B09B-2186AB9AA3AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DD6985D-35AC-4154-B09B-2186AB9AA3AD}.Release|Any CPU.Build.0 = Release|Any CPU
{EB78BBEC-4D8A-456C-90F1-920E45FFF982}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB78BBEC-4D8A-456C-90F1-920E45FFF982}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB78BBEC-4D8A-456C-90F1-920E45FFF982}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB78BBEC-4D8A-456C-90F1-920E45FFF982}.Release|Any CPU.Build.0 = Release|Any CPU
{F6E21C47-44DA-4569-AE39-6093C9222E03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6E21C47-44DA-4569-AE39-6093C9222E03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6E21C47-44DA-4569-AE39-6093C9222E03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6E21C47-44DA-4569-AE39-6093C9222E03}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
29 changes: 29 additions & 0 deletions C4Interflow.Specs/C4Interflow.Specs.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\C4InterFlow.Automation\C4InterFlow.Automation.csproj" />
<ProjectReference Include="..\C4InterFlow.Cli\C4InterFlow.Cli.csproj" />
</ItemGroup>

<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>
23 changes: 23 additions & 0 deletions C4Interflow.Specs/DrawDiagrams/Examples.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Feature: Drawing Diagrams
Test out different combinations of drawing diagrams

Scenario: Verify Examples
Given the 'draw-diagrams' command
And the '<Example>' example
And the path '<Path>'
And the reader strategy is '<ReaderStrategy>'
And the interfaces are '<Interfaces>'
And the business processes are '<BusinessProcesses>'
And the level of details is '<LevelOfDetails>'
And send the output to '<OutputPath>'
When invoking the commandline for those arguments
Then all files under '<OutputPath>' should match example path '<ApprovedOutPath>'

Examples:
| Description | Example | Path | ReaderStrategy | Interfaces | BusinessProcesses | LevelOfDetails | OutputPath | ApprovedOutPath |
| Banking System via Yaml | Internet Banking System | CSV\Architecture\Yaml | Yaml | BigBankPlc.SoftwareSystems.*.Containers.*.Interfaces | BigBankPlc.BusinessProcesses.* | context container | _bankingYaml | Internet Banking System\CSV\Diagrams |
| Banking System via Json | Internet Banking System | CSV\Architecture\Json | Json | BigBankPlc.SoftwareSystems.*.Containers.*.Interfaces | BigBankPlc.BusinessProcesses.* | context container | _bankingJson | Internet Banking System\CSV\Diagrams |
| ECommerce via Yaml | E-Commerce Platform | Yaml\Architecture | Yaml | ECommercePlatform.*.*.SoftwareSystems.*.Interfaces.* ECommercePlatform.*.*.SoftwareSystems.*.Containers.*.Interfaces.* | ECommercePlatform.BusinessProcesses.* | context container | _ecommerceYaml | E-Commerce Platform\Yaml\Diagrams |
| TraderX via Json | TraderX | CSV\Architecture\Json | Json | TraderXExample.SoftwareSystems.*.Containers.*.Interfaces.* | TraderXExample.BusinessProcesses.* | context container | _traderXJson | TraderX\CSV\Diagrams |
| TraderX via Yaml | TraderX | CSV\Architecture\Yaml | Yaml | TraderXExample.SoftwareSystems.*.Containers.*.Interfaces.* | TraderXExample.BusinessProcesses.* | context container | _traderXYaml | TraderX\CSV\Diagrams |
| ToDoApp via Yaml | ToDoApp | Yaml\Architecture | Yaml | ToDoAppExample.SoftwareSystems.*.Containers.*.Interfaces.* ToDoAppExample.SoftwareSystems.*.Interfaces.* | | container | _todoYaml | ToDoApp\Yaml\Diagrams |
Loading