Task 1
Write xUnit tests for a late-fee rule: no fee up to 10 days late, then 5% of the instalment, at least 25 and at most 100. Cover the edges.
Question index (Must): write xUnit tests for a LoanService method, AAA and TheoryStuck? Hints
- Which days matter most? Look at where the rule changes.
- How do you test 25, 40 and 100 without three copies of the same test?
- Where does today's date come from in your test?
Show a solution
Lending.sln · where this file sits
- Day 10 (no fee) and day 11 (fee) are both tested.
- Minimum and maximum hit, plus one normal value.
[Theory]with[InlineData]for the amounts.- Fixed dates; nothing reads the real clock.
- Arrange, Act, Assert, names that describe the behaviour.
- Senior extra: says what an integration test would add.