Adding tests for filewatcher sources#1
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an xUnit-based test suite that auto-discovers FileWatcherSourceBase implementations via reflection and validates key behaviors (startup scan, file create detection, subdirectory watching, debouncing / single-emission).
Changes:
- Added
FileWatcherSourceTeststo exercise file-watcher sources against real filesystem events. - Added reflection-based discovery helpers (
FileWatcherSourceDiscovery) and xUnitMemberDatagenerator (FileWatcherTestData). - Introduced basic exclusions (Tekken8) and source grouping by subdirectory support.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| GamesDat.Tests/Helpers/FileWatcherTestData.cs | Generates xUnit MemberData for discovered file watcher sources (and subdirectory groupings). |
| GamesDat.Tests/Helpers/FileWatcherSourceDiscovery.cs | Reflection-based discovery + pattern/subdirectory extraction + source instantiation helper. |
| GamesDat.Tests/FileWatcherSourceTests.cs | New parameterized tests validating file watcher source behavior on the filesystem. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address code review feedback from PR #1 with the following improvements: **Resource Management:** - Add `using` declarations to all test methods for proper disposal - Implement try/finally blocks to ensure cleanup even on assertion failures - Guarantee CancellationTokenSource cancellation and task awaiting in all paths **Type Safety:** - Replace string-based type exclusions with typeof() comparisons - Add explicit Tekken8ReplayFileSource import for compile-time verification **Pattern Discovery:** - Support both ApplyDefaults(FileWatcherOptions) and ApplyDefaults(string?) overloads - Throw InvalidOperationException when patterns cannot be retrieved - Validate patterns in test data generation (fail-fast on missing configuration) **Test Coverage:** - Update AllDiscoveredSources_AreInstantiable to use DiscoverAllSources() directly - Ensure all discovered sources are validated (no silent exclusions) - Add explicit pattern validation for all sources except Tekken8 These changes ensure reliable test cleanup, prevent resource leaks, and guarantee complete test coverage of all FileWatcher source implementations. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Review Comment ResponsesThank you for the thorough review! I've addressed 7 of the 9 comments in commit 4801846. Here's a summary: ✅ Addressed Comments1. Type-Safe Exclusions (FileWatcherTestData.cs:27, 60)
2. Resource Management (FileWatcherSourceTests.cs:60, 145, 230, 300, 382, 468)
3. Reliable Cleanup (FileWatcherSourceTests.cs - all async tests)
4. Complete Source Validation (FileWatcherSourceTests.cs:549-576)
5. Comprehensive Pattern Discovery (FileWatcherSourceDiscovery.cs:96-130)
6. Fail-Fast Pattern Retrieval (FileWatcherSourceDiscovery.cs:56-68)
7. Pattern Validation in Test Data (FileWatcherTestData.cs:32-38, 71-77)
📝 Not Addressed (Style Suggestions)8 & 9. Using explicit .Where() instead of continue I've opted to keep the current
If you feel strongly about using |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add explicit System.IO import to FileWatcherSourceDiscovery - Fix constructor invocation to use Array.Empty<object>() instead of null - Add test for sources without subdirectory support Addresses Copilot PR review comments: 1. Missing namespace import for Path.GetTempPath() 2. Unused SourcesWithoutSubdirectories() test data method 3. Incorrect constructor invocation with null parameter The new test gracefully handles sources with inconsistent subdirectory configuration between ApplyDefaults and string constructors. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Auto-discovers file watcher sources and tests that they work correctly. We exclude Tekken for now since I do not know what the file extension is yet.