Exercise project with Order domain and NUnit tests demonstrating the 'show, don't tell' pattern for guiding coding agents. - 1 refactored test using custom matcher (the example) - 5 unrefactored tests with multiple asserts (the practice) - OrderStateConstraint custom matcher for NUnit 3
20 lines
458 B
C#
20 lines
458 B
C#
namespace OrderDomain;
|
|
|
|
public class OrderLine
|
|
{
|
|
public decimal UnitPrice { get; }
|
|
public int Quantity { get; }
|
|
public bool HasDiscount { get; private set; }
|
|
|
|
public decimal Value =>
|
|
HasDiscount ? UnitPrice * Quantity * 0.8m : UnitPrice * Quantity;
|
|
|
|
public OrderLine(decimal unitPrice, int quantity)
|
|
{
|
|
UnitPrice = unitPrice;
|
|
Quantity = quantity;
|
|
}
|
|
|
|
public void ApplyDiscount() => HasDiscount = true;
|
|
}
|