# C# Testing and Dependencies Apply these rules when changing tests, package references, analyzers, or build diagnostics. * Write deterministic behavior-based tests. Avoid coupling assertions to private call order, implementation details, or uncontrolled external services. Inject `TimeProvider` (.NET 8+) instead of reading `DateTime.Now`, and use `FakeTimeProvider` from `Microsoft.Extensions.TimeProvider.Testing` in tests. * Make code testable through clear contracts and dependencies; do not add production hooks or abstractions solely for tests without a concrete need. * Prefer the .NET BCL and existing supported packages over new libraries when they solve the problem adequately. * Treat compiler, analyzer, and nullable warnings seriously. Suppress a diagnostic only for a specific, documented reason and narrow the suppression to the affected code. * Build the changed projects with analyzers enabled and warnings visible. Where the project sets `TreatWarningsAsErrors`, `AnalysisLevel`, or `EnforceCodeStyleInBuild`, never lower them to get a green build, and respect `.editorconfig`. * Add or update packages through Central Package Management (`Directory.Packages.props`) when the repository uses it. Keep NuGetAudit enabled; it audits transitive packages by default only for `net10.0`+ projects, so prefer `NuGetAuditMode` `all` for older targets when the project allows it.