An audit system records organizational visitor names and visit times in sequential flat text files, rolling to a new file when the current file reaches its entry limit. section 6.4
Its core workflow is:
- Find and sort files by their numeric index. section 6.4
- Create audit_1.txt when no audit files exist. section 6.4
- Append to the latest file when capacity remains; otherwise create the next indexed file. section 6.4
Filesystem coupling makes direct tests slow, difficult to maintain, and hard to parallelize. A functional architecture separates file persistence from AuditManager’s decision logic and enables output-based tests. section 6.4
Testing overflow as an output
Supply FileContent values to AuditManager, add Alice’s visit, and assert a FileUpdate containing audit_3.txt and the serialized record. The test avoids mocks and filesystem setup.
