Skip to content

Commit

Permalink
#24: Added additional Sequence Diagram sample for accessing database
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinCelej committed Jul 13, 2023
1 parent 8d52ef5 commit 54294a0
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Technical Debt for Synergy.Contracts

Total: 9
Total: 8

## [SequenceDiagramDeactivationAttribute.cs](../../../Synergy.Architecture.Annotations/Diagrams/Sequence/SequenceDiagramDeactivationAttribute.cs)
- TODO: Marcin Celej [from: Marcin Celej on: 21-05-2023]: Use this attribute in some sample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Synergy.Architecture.Diagrams.Documentation;
using Synergy.Architecture.Diagrams.Sequence;
using Synergy.Documentation.Code;
using static Synergy.Architecture.Annotations.Diagrams.Sequence.SequenceDiagramGroupType;

namespace Synergy.Architecture.Tests.Samples;

Expand All @@ -15,14 +16,15 @@ public async Task Sequence()
{
var blueprint = TechnicalBlueprint
.Titled("Sequence diagrams samples")
.Add(SequenceDiagramSamples.IfElseDiagrams())
.Add(LoopAfterLoopDiagram())
.Add(this.IfElseDiagrams())
.Add(this.LoopAfterLoopDiagram())
.Add(this.DatabaseDiagrams())
;

await File.WriteAllTextAsync(SequenceDiagrams.FilePath, blueprint.Render());
}

private static IEnumerable<SequenceDiagram> IfElseDiagrams()
private IEnumerable<SequenceDiagram> IfElseDiagrams()
{
yield return SequenceDiagram
.From(new SequenceDiagramActor("Some actor", Note: "very hand some"))
Expand All @@ -36,9 +38,9 @@ private static IEnumerable<SequenceDiagram> IfElseDiagrams()
[SequenceDiagramExternalCall("Firefox", "https://www.google.com", Group = SequenceDiagramGroupType.Else, GroupHeader = "otherwise")]
private void IfElse()
{
}
}

private static IEnumerable<SequenceDiagram> LoopAfterLoopDiagram()
private IEnumerable<SequenceDiagram> LoopAfterLoopDiagram()
{
yield return SequenceDiagram
.From(new SequenceDiagramActor("Some actor", Note: "very hand some"))
Expand All @@ -47,12 +49,26 @@ private static IEnumerable<SequenceDiagram> LoopAfterLoopDiagram()
);
}

[SequenceDiagramExternalCall("Chrome", "https://www.google.com", Group = SequenceDiagramGroupType.Loop, GroupHeader = "Looping until something happens")]
[SequenceDiagramExternalCall("Firefox", "https://www.foogle.com", Group = SequenceDiagramGroupType.Loop, GroupHeader = "Looping until something happens")]
[SequenceDiagramExternalCall("Firefox", "https://www.google.com", Group = SequenceDiagramGroupType.Loop, GroupHeader = "This should be different loop")]
[SequenceDiagramExternalCall("Chrome", "https://www.google.com", Group = Loop, GroupHeader = "Looping until something happens")]
[SequenceDiagramExternalCall("Firefox", "https://www.foogle.com", Group =Loop, GroupHeader = "Looping until something happens")]
[SequenceDiagramExternalCall("Firefox", "https://www.google.com", Group =Loop, GroupHeader = "This should be different loop")]
private void LoopAfterLoop()
{
}


private IEnumerable<SequenceDiagram> DatabaseDiagrams()
{
yield return SequenceDiagram
.From(new SequenceDiagramActor("Some actor", Note: "very hand some"))
.Calling<SequenceDiagramSamples>(c => c.Database())
.Footer("This diagram shows standard database operations."
);
}

[SequenceDiagramDatabaseCall($"SELECT * FROM [Item] WHERE [Id] = @itemId")]
[SequenceDiagramDatabaseCall($"INSERT INTO [Item] VALUES ...", Group = Alt, GroupHeader = "if item does not exist yet")]
[SequenceDiagramDatabaseCall($"Item [Table] SET ... WHERE [Id] = @itemId", Group = Else, GroupHeader = "else")]
private void Database()
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,38 @@ Some_actor<--SequenceDiagramSamples
This diagram shows loop placed after another loop.


## SequenceDiagramSamples.Database()

**Root type:** `SequenceDiagramSamples` (from: `Synergy.Architecture.Tests`)

**Root method:**
```
Database() : void
```

![Sequence Diagram for SequenceDiagramSamples.Database()](http://www.plantuml.com/plantuml/png/Z59DJm8n5Bnlil_XXPEQBDw94b3MI0AIiAiU234F-e36tUtQzn3zRHxyIVu5t_8L3f1mQJlDp7IcxT_FRui5lIppB0putHObUip14vUkOEeJCyxfZZAtQdllLY1-IM4mSqx8Gxgm3CRYlDBmmgqOrAqmw0qO59mW4xYIF8fLkteOY9LCzGbzBAcOKcUZJJ0lC-9wPwkvk0m3AioMZ5Dn7XANqzjcYGor2i8QriBW6WhD0-wJ3daDKFmD2mq4hBjXeEN4Jcs9XS3n266mpxqBesdtbb7pkAm1Xz6FSwBcZjE09Ex5zobSmSDmq8THLoWVm-jZF8mLc37SGilgNjTe-qp0pg22O1nnLHNeoxB0DyavXtMVadYOwfGETaUzj7lFSGBrkZu9PLgs6ixogcACKfnaDDOMQMLn8hW-uE7LtKJHgIjlANNz0Vy1003__mC0)
<!--
@startuml
skinparam responseMessageBelowArrow true
footer This diagram shows standard database operations.
title
SequenceDiagramSamples.Database()
endtitle
actor Some_actor as "Some actor"
/ note over Some_actor: very hand some
participant SequenceDiagramSamples
database Database
Some_actor->SequenceDiagramSamples: Database()
SequenceDiagramSamples->Database: SELECT * FROM [Item] WHERE [Id] = @itemId
alt if item does not exist yet
SequenceDiagramSamples->Database: INSERT INTO [Item] VALUES ...
else else
SequenceDiagramSamples->Database: Item [Table] SET ... WHERE [Id] = @itemId
end
Some_actor<--SequenceDiagramSamples
@enduml
-->

This diagram shows standard database operations.


0 comments on commit 54294a0

Please sign in to comment.