Repository navigation
Testing
Michael Riddle edited this page Aug 19, 2026
·
3 revisions
# Just the unit tests
dotnet test tests/KHost.UnitTests
# Narrow to one class/test
dotnet test tests/KHost.UnitTests --filter "FullyQualifiedName~Name"
# Everything in the solution
dotnet test KHost.slnxxUnit + NSubstitute. Test classes mirror the src/ layout (Domain/Services/Foo.cs → Domain/Services/FooTests.cs); names follow MethodUnderTest_Scenario_ExpectedBehavior; substitutes live in field initializers; StateChanged is tested with a counter lambda.
Notable infrastructure:
-
SqliteTestDatabase— repository tests run against a real in-memory SQLite database (schema from the EF model, not migrations, so the raw FTS5 SQL isn't needed). Repository LINQ only becomes real SQL at the provider, so faking the provider would test expression trees, not behavior. -
AsyncNamingConventionTests(Conventions/) — reflection sweep across all eight referenced assemblies asserting everyTask/ValueTask-returning method ends inAsync. A new project needs aProjectReferencefromKHost.UnitTeststo be covered. -
EnvironmentCoverageTests— the transcode tests run real ffmpeg (and use ffprobe to assert a segment carries audio). If either is missing, this suite fails the run in plain words rather than letting silently-skipped coverage read as a pass. SetKHOST_SKIP_ENVIRONMENT_TESTS=1to accept the gap. -
Cast tests need the Chromecast-Emulator listening on
127.0.0.1:8009; they skip (via a 1-second connect probe) when it isn't. - Plugin loader tests cover discovery failure modes (missing/invalid manifest, duplicate id, API version mismatch, missing entry assembly) and end-to-end load/registration.
Empty skeleton — only the .csproj exists (no tests, no project references). It builds and runs (0 tests) as part of the solution; new integration tests belong here.
KHost
Architecture
- Architecture
- Projects
- Screens and Casting
- Break Music and Ads
- Messaging
- Data and Persistence
- Plugins
Contributing