Seven Tests to Run Before Trusting a .NET Play Counter
A simple play counter can pass manual testing yet still overcount retried requests, lose plays after worker crashes, or let scripts inflate totals. The author built a Spotify-style counter in .NET 10 by first writing tests that would expose these failures, starting with the rules that a stream counts after 30 seconds and offline plays must sync within 30 days. Boundary tests around the 30-second threshold matter because off-by-one errors affect royalties, and the 30-day rule determines when clients should stop retrying. Duplicate-event tests verify that redelivered messages are not counted twice, since queues typically deliver at least once. A further test checks that concurrent writers trigger a replan rather than a double count, with the commit marking event IDs as seen in a single atomic step.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in