Fix Concept section: use IsFullyPaid() example, not custom matcher
The Concept demo should show a different pattern (encapsulate behavior) than the exercise (custom matcher) so the exercise stays fresh.
This commit is contained in:
@@ -44,10 +44,10 @@ The agent might:
|
|||||||
|
|
||||||
### The "Show" Approach (works better)
|
### The "Show" Approach (works better)
|
||||||
|
|
||||||
Refactor one test yourself:
|
Refactor one test yourself — encapsulate the attribute check behind a behavior method:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
// Before — telling attributes
|
// Before — checking an attribute
|
||||||
[Test]
|
[Test]
|
||||||
public void CompletedOrder_TotalIsCorrect()
|
public void CompletedOrder_TotalIsCorrect()
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,6 @@ public void CompletedOrder_TotalIsCorrect()
|
|||||||
order.Complete();
|
order.Complete();
|
||||||
|
|
||||||
Assert.That(order.Total, Is.EqualTo(100m));
|
Assert.That(order.Total, Is.EqualTo(100m));
|
||||||
Assert.That(order.Status, Is.EqualTo("completed"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// After — encapsulating behavior
|
// After — encapsulating behavior
|
||||||
@@ -67,13 +66,13 @@ public void CompletedOrder_TotalIsCorrect()
|
|||||||
order.AddLine(100m, 1);
|
order.AddLine(100m, 1);
|
||||||
order.Complete();
|
order.Complete();
|
||||||
|
|
||||||
Assert.That(order, Has.OrderTotalCorrect(100m));
|
Assert.That(order.IsFullyPaid(100m), Is.True);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Then ask the agent:
|
Then ask the agent:
|
||||||
|
|
||||||
> The first test was refactored to use `Has.OrderTotalCorrect()`. Apply the same pattern to the remaining tests.
|
> The first test was refactored to use `order.IsFullyPaid(expected)` instead of asserting on `order.Total`. Apply the same pattern to the remaining tests.
|
||||||
|
|
||||||
The agent sees the concrete pattern and replicates it. No description needed.
|
The agent sees the concrete pattern and replicates it. No description needed.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user