The checks use the same files as the application, with Checks.cs in place of Program.cs. Press Run. A healthy result is a single line.
Read Checks.cs and notice what it tests. The boundary cases come from the brief, and each failure message names the rule.
Break it on purpose
Each change below is a realistic slip. Make one at a time in the tabs above, press Run, and confirm that a check fails. Then undo it.
| File | Change | What should fail |
|---|---|---|
Tracker.cs | trimmed.Length > MaxTitleLength to >= | The 60-character title is refused |
Tracker.cs | tasks.Max(task => task.Id) + 1 to tasks.Count + 1 | Ids continue after the highest loaded |
Stores.cs | loaded ?? throw new StoreFormatException($"{path} is not valid task data") to loaded ?? new List<TaskItem>() | Refuses saved data: null |
Reports.cs | task.Due < today to <= | A task due today counts as overdue |
Reports.cs | Remove !task.Done && | Finished tasks count as overdue |
Reports.cs | ThenByDescending to ThenBy | Low priority sorts first |
The project's own automated tests apply these changes and more, on every run. If one of them ever stopped failing, that test would report a mutation that had survived.
The fake store
Tracker.Load handles failures, but a real disk rarely fails on command. FakeStore implements ITaskStore and can throw whatever a check asks for. Here's the idea at its smallest. Predict the result, then see how the tasks are protected.
#nullable enable
var book = new Book();
book.Load(new FakeStore(new List<string> { "kept" }));
Console.WriteLine(book.Titles.Count);
Console.WriteLine(book.Load(new FakeStore(null)));
Console.WriteLine(book.Titles[0]);
interface IStore
{
List<string> Load();
}
class FakeStore(List<string>? saved) : IStore
{
public List<string> Load() => saved ?? throw new IOException("disk");
}
class Book
{
private readonly List<string> titles = new();
public IReadOnlyList<string> Titles => titles;
public string Load(IStore store)
{
List<string> loaded;
try
{
loaded = store.Load();
}
catch (IOException e)
{
return $"failed: {e.Message}";
}
titles.Clear();
titles.AddRange(loaded);
return "loaded";
}
}Check your prediction
1
failed: disk
keptRound-trip checks
The most valuable storage check saves data with the real code, loads it back, and compares. Because records have value equality, comparing is one line. A list compares by reference, though, so use SequenceEqual.
#nullable enable
using System.Text.Json;
var original = new List<Item> { new(1, "Read"), new(2, "Write, then edit") };
string json = JsonSerializer.Serialize(original);
List<Item>? restored = JsonSerializer.Deserialize<List<Item>>(json);
Console.WriteLine(restored == original);
Console.WriteLine(restored!.SequenceEqual(original));
record Item(int Id, string Title);Check your prediction
False
TrueThe ! is safe here. This JSON was written a moment ago, so it can't be the literal null.
Your turn
Test a rule table
The tracker's Overdue rule depends on three facts: whether the task is done, and whether it's due before, on or after today. Write a table-driven check with all six combinations for IsOverdue(DateOnly due, bool done, DateOnly today), then a correct IsOverdue. Print Overdue checks passed if nothing fails. Try changing < to <= to see a row fail.
When every check passes, it prints:
Overdue checks passedvar today = new DateOnly(2026, 11, 2);
Console.WriteLine(today.AddDays(-1) < today);Hint 1: the idea
Done can be true or false, and the date can be yesterday, today or tomorrow. Two times three gives your six rows, and only one row expects true.
Hint 2: a first step
Make an array of (int Offset, bool Done, bool Expected) tuples, and use today.AddDays(offset) in the loop to build each due date.
Show one solution
var today = new DateOnly(2026, 11, 2);
var rows = new (int Offset, bool Done, bool Expected)[]
{
(-1, false, true),
(0, false, false),
(1, false, false),
(-1, true, false),
(0, true, false),
(1, true, false),
};
int failures = 0;
foreach (var (offset, done, expected) in rows)
{
if (IsOverdue(today.AddDays(offset), done, today) != expected)
{
Console.WriteLine($"FAILED: offset {offset}, done {done}");
failures++;
}
}
if (failures == 0)
{
Console.WriteLine("Overdue checks passed");
}
static bool IsOverdue(DateOnly due, bool done, DateOnly today) => !done && due < today;Overdue checks passedThe rows cover every combination of the two inputs: due yesterday, today and tomorrow, each both open and done. Offsets from today keep the table readable and make "due today" an exact case, which is the one an off-by-one mistake would break. A fixed today means the check gives the same answer on any day you run it.
Completion is saved in this browser only. It does not measure mastery.