1
0
mirror of https://github.com/bitwarden/server synced 2026-01-27 14:53:21 +00:00

Refactor BaseRequestValidatorTests to use SutProvider pattern

- Replace manual constructor-based dependency injection with SutProvider<T>
- Add [SutProviderCustomize] attribute to test class
- Update all 25+ test methods to use sutProvider parameter
- Handle FakeLogger special case with SetDependency<ILogger>()
- Update CLAUDE.md with SutProvider advanced usage documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Patrick Pimentel
2026-01-22 11:50:30 -05:00
parent c7cc36442a
commit f5b0c3aa2b
2 changed files with 399 additions and 544 deletions

View File

@@ -114,6 +114,11 @@ Key testing utilities:
- `SutProvider<T>` - Helper for creating system-under-test with mocked dependencies
- `[SutProviderCustomize]` - Attribute to enable SutProvider pattern
**SutProvider advanced usage:**
- **Parameter order with inline data**: `[BitAutoData("value")]` inline parameters come before `SutProvider<T>` in the method signature
- **Non-mock dependencies**: Use `new SutProvider<T>().SetDependency<IInterface>(realInstance).Create()` when you need a real implementation (e.g., `FakeLogger`) instead of a mock
- **Interface matching**: SutProvider matches dependencies by the exact interface type in the constructor
### Integration Tests
Integration tests exercise real code paths with actual database operations. **Do not mock** - use real repositories and test helpers to set up data: