Skip to content

Commit

Permalink
#14: I added step 5 to Business documentaion: generate automatically …
Browse files Browse the repository at this point in the history
…markdown documentation
  • Loading branch information
MarcinCelej committed Feb 21, 2022
1 parent ad04b29 commit 829bcfb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Business.Rule("When withdraw limit is set, withdrawn amount cannot exceed the li
.Throws(new WithdrawAmountExceedsLimitException(withdrawLimit, withdrawAmount));
```

### Fifth step: generate automatically markdown documentation

TODO: Describe how to convert the code to human readable markdown file using Unit Tests and ApprovalTests framework

### More samples

``` csharp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public void General()
.Append(this.Step2MakeItWorking())
.Append(this.Step3IntroduceDedicatedException())
.Append(this.Step4DocumentTheRequirement())
.Append(this.Step5GenerateDocumentation())
.Append(this.QuickSamples())
.Append(this.ValueObjectExample())
;
Expand Down Expand Up @@ -138,21 +139,7 @@ private void Step4Sample(int withdrawLimit, int withdrawAmount)
foreach (var element in this.Sample1().Union(this.Sample2()))
yield return element;
}

private IEnumerable<Markdown.IElement> Sample2()
{
TransactionType transactionType = TransactionType.OnlinePayment;
double? onlinePaymentLimit = 10;
double paymentAmount = 11;

this.Act(() =>
this.QuickSample2(transactionType, onlinePaymentLimit, paymentAmount)
)
.AssertException($"Online Payment Amount ({paymentAmount}) exceeds the Online Payment Limit ({onlinePaymentLimit})");

yield return new Markdown.Code(ClassReader.ReadMethodBody(nameof(this.QuickSample2)));
}


private IEnumerable<Markdown.IElement> Sample1()
{
var balance = -10;
Expand All @@ -171,6 +158,20 @@ private void QuickSample1(int balance)
.Throws($"balance cannot be < 0 and actually is {balance}");
}

private IEnumerable<Markdown.IElement> Sample2()
{
TransactionType transactionType = TransactionType.OnlinePayment;
double? onlinePaymentLimit = 10;
double paymentAmount = 11;

this.Act(() =>
this.QuickSample2(transactionType, onlinePaymentLimit, paymentAmount)
)
.AssertException($"Online Payment Amount ({paymentAmount}) exceeds the Online Payment Limit ({onlinePaymentLimit})");

yield return new Markdown.Code(ClassReader.ReadMethodBody(nameof(this.QuickSample2)));
}

private void QuickSample2(TransactionType transactionType, double? onlinePaymentLimit, double paymentAmount)
{
Business.Rule("For online payment transaction: when online payment limit is set than payment amount cannot exceed the limit")
Expand Down

0 comments on commit 829bcfb

Please sign in to comment.