Skip to content

test: add ClassifyContentAsyncTests — cover all 3 branches (null response, exception, type-switch)#175

Open
davidortinau wants to merge 1 commit into
mainfrom
op-test-classify-content-async
Open

test: add ClassifyContentAsyncTests — cover all 3 branches (null response, exception, type-switch)#175
davidortinau wants to merge 1 commit into
mainfrom
op-test-classify-content-async

Conversation

@davidortinau

Copy link
Copy Markdown
Owner

What

Adds ClassifyContentAsyncTests.cs — 6 xUnit tests that directly exercise every code path in ContentImportService.ClassifyContentAsync (ContentImportService.cs:870), which was previously untested. Existing tests mock away classification by pre-setting ContentType on the request, so the mapping and fallback logic had zero coverage.

Also adds [InternalsVisibleTo("SentenceStudio.UnitTests")] via a new AssemblyInfo.cs in the Shared project to expose the internal ContentClassificationAiResponse DTO to the test project.

Why

ClassifyContentAsync is the hot auto-detect path on the feature/import-content branch. Without direct tests, regressions in any of its three branches (null AI response, AI exception, type-switch mapping) would only surface as silent wrong behaviour in integration.

Tests added

Test Branch covered
ClassifyContent_NullAiResponse_DefaultsToVocabulary Null response → Vocabulary / 0.5f confidence
ClassifyContent_AiException_DefaultsWithLowConfidence Exception → Vocabulary / 0.3f + "error" signal
ClassifyContent_KnownType_MapsCorrectly (Theory ×4) vocabulary, phrases, sentences, transcript arms
ClassifyContent_UnknownType_FallsBackToVocabulary Wildcard _ arm → Vocabulary

Verification

dotnet test tests/SentenceStudio.UnitTests/
Passed! Failed: 0, Passed: 495, Skipped: 0, Total: 495

489 pre-existing tests all still pass.

 Vocabulary / 0.5f confidence
 Vocabulary / 0.3f confidence with error signals
- 4-arm type-switch (vocabulary, phrases, sentences, transcript)
 Vocabulary fallback

Also adds [InternalsVisibleTo("SentenceStudio.UnitTests")] via
src/SentenceStudio.Shared/AssemblyInfo.cs to expose the internal
ContentClassificationAiResponse DTO to the test project.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant