Skip to content

Refs #159: migrate Dashboard.Api.Tests to MSTest assertions (Phase 5)#175

Merged
blehnen merged 4 commits into
masterfrom
phase-5-dashboard-api-tests
Jul 3, 2026
Merged

Refs #159: migrate Dashboard.Api.Tests to MSTest assertions (Phase 5)#175
blehnen merged 4 commits into
masterfrom
phase-5-dashboard-api-tests

Conversation

@blehnen

@blehnen blehnen commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Part of #159 (replace FluentAssertions with MSTest assertions), Milestone 2, Phase 5.

Migrates all 22 files in DotNetWorkQueue.Dashboard.Api.Tests (352 .Should() sites) off FluentAssertions to built-in MSTest assertions, and removes the project's FA PackageReference. Test-only; no production code, no version bump.

Scope

  • Configuration/ (5) + Models/ (4) — includes 6 throws + all 3 WithMessage sites
  • Controllers/ (3) + Middleware/ (2) — BeOfType/.Subject chains
  • Services/ (3, incl. 91-site DashboardServiceTests) + Extensions/ (4) + root DashboardApiTests.cs

Mapping notes

  • .Should().Throw<T>()Assert.Throws<T> (T-or-derived); async → await Assert.ThrowsAsync<T>
  • .WithMessage("*sub*") → capture ex, Assert.IsTrue(ex.Message.Contains("sub", StringComparison.OrdinalIgnoreCase)) (FA WithMessage is case-insensitive)
  • .Should().BeEquivalentTo(arr) (CORS origins, string collection) → CollectionAssert.AreEquivalentno Tests.Shared helper needed (no object-graph equivalence in this project)
  • InterceptorChain ContainCollectionAssert.Contains; string ContainStringAssert.Contains
  • BeOfType<T>()Assert.IsInstanceOfType<T>; .Subject → cast
  • Swapped the FluentAssertions.dll preload test fixture in DashboardExtensionsTests to Newtonsoft.Json.dll (the copied DLL must still exist in bin after FA is removed)

Verification

  • Release build (TreatWarningsAsErrors): 0 warnings / 0 errors (net10.0 + net8.0)
  • Grep: zero FluentAssertions / .Should() in the project
  • dotnet test: 216 / 216 passed on both TFMs (clean, FA-free build)
  • Source/Directory.Packages.props untouched — FA pin removed solution-wide in Phase 8

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Modernized the dashboard test suite to use built-in assertion tools consistently.
    • Improved coverage checks for configuration, controllers, services, middleware, and health responses.
    • Updated exception and collection validations to be clearer and more uniform.
    • Removed an unused test dependency from the project.

blehnen and others added 4 commits July 3, 2026 15:21
…ssertions

Plan 1.1 (#159): 9 files, 76 sites. Throws -> Assert.Throws<T>; WithMessage ->
ex.Message.Contains(..., OrdinalIgnoreCase). No helper needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… assertions

Plan 1.2 (#159): 5 files. BeOfType -> IsInstanceOfType; .Subject -> cast.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Test assertions

Plan 1.3 (#159): 8 files incl. 91-site DashboardServiceTests. Async ThrowAsync ->
Assert.ThrowsAsync; BeEquivalentTo -> CollectionAssert.AreEquivalent; InterceptorChain
Contain -> CollectionAssert.Contains, string Contain -> StringAssert.Contains.
Swapped FluentAssertions.dll preload fixture -> Newtonsoft.Json.dll (survives FA removal).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…board.Api.Tests csproj

Plan 1.4 (#159): project is FA-free (216/216 green net10+net8, Release 0/0, grep-zero).
Directory.Packages.props untouched (FA pin removed solution-wide in Phase 8).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 24098b53-bbf0-44ac-ab2e-662570b6182f

📥 Commits

Reviewing files that changed from the base of the PR and between 8f5acc7 and f279ff5.

📒 Files selected for processing (23)
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardConnectionOptionsTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardInterceptorOptionsTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardOptionsTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardQueueOptionsTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/InterceptorConfigurationBuilderTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/ConnectionsControllerTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/ConsumersControllerTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/QueuesControllerTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/DashboardApiTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/DotNetWorkQueue.Dashboard.Api.Tests.csproj
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsCorsAndAuthTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsFromConfigurationTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsSwaggerTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Middleware/ApiKeyAuthorizationFilterTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Middleware/DashboardExceptionFilterTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/BulkActionResponseTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/DashboardSettingsResponseTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/ErrorRetryResponseTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/HistoryResponseTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/ConsumerRegistryTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/DashboardHealthCheckTests.cs
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/DashboardServiceTests.cs
💤 Files with no reviewable changes (1)
  • Source/DotNetWorkQueue.Dashboard.Api.Tests/DotNetWorkQueue.Dashboard.Api.Tests.csproj

📝 Walkthrough

Walkthrough

This PR migrates the DotNetWorkQueue.Dashboard.Api.Tests project's assertion library from FluentAssertions to MSTest's built-in Assert, StringAssert, and CollectionAssert APIs across all test files, and removes the FluentAssertions package reference from the project file. No production code or public API declarations are changed.

Changes

Test Framework Migration

Layer / File(s) Summary
Configuration tests
Configuration/DashboardConnectionOptionsTests.cs, Configuration/DashboardInterceptorOptionsTests.cs, Configuration/DashboardOptionsTests.cs, Configuration/DashboardQueueOptionsTests.cs, Configuration/InterceptorConfigurationBuilderTests.cs
Assertions for queue/interceptor configuration, options defaults, and profile-lookup exceptions are converted from Should() to Assert.* calls.
Controller tests
Controllers/ConnectionsControllerTests.cs, Controllers/ConsumersControllerTests.cs, Controllers/QueuesControllerTests.cs
Result-type, status-code, and payload assertions across connection/consumer/queue controller tests are rewritten using Assert.IsInstanceOfType, Assert.AreEqual, and related MSTest calls.
Core dashboard tests and project file
DashboardApiTests.cs, DotNetWorkQueue.Dashboard.Api.Tests.csproj
Core API tests use MSTest null/exception assertions; the FluentAssertions NuGet reference is removed from the test project.
Extension registration tests
Extensions/DashboardExtensionsCorsAndAuthTests.cs, Extensions/DashboardExtensionsFromConfigurationTests.cs, Extensions/DashboardExtensionsSwaggerTests.cs, Extensions/DashboardExtensionsTests.cs
CORS, authorization, configuration-driven registration, Swagger, and assembly-preload tests switch to MSTest/CollectionAssert/StringAssert checks; a preload fixture DLL changes from FluentAssertions.dll to Newtonsoft.Json.dll.
Middleware filter tests
Middleware/ApiKeyAuthorizationFilterTests.cs, Middleware/DashboardExceptionFilterTests.cs
API key authorization and exception filter result/status assertions are rewritten with MSTest Assert calls.
Model tests
Models/BulkActionResponseTests.cs, Models/DashboardSettingsResponseTests.cs, Models/ErrorRetryResponseTests.cs, Models/HistoryResponseTests.cs
Property getter/setter and round-trip tests for response models use Assert.AreEqual/Assert.IsNull/Assert.IsTrue in place of FluentAssertions.
Service tests
Services/ConsumerRegistryTests.cs, Services/DashboardHealthCheckTests.cs, Services/DashboardServiceTests.cs
Consumer registry, health check, and dashboard service behavior tests (registration, heartbeats, metrics, message body/header decoding, error handling) are converted to MSTest assertion equivalents.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related issues

Possibly related PRs

Poem

A rabbit hopped through lines of test,
Swapped "Should().Be" for "Assert" — the best!
No more fluent chains to bind,
Just crisp checks of every kind.
🐇✨ Green checkmarks, tests at rest.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: migrating Dashboard.Api.Tests to MSTest assertions in phase 5.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.44%. Comparing base (5e5ad7e) to head (f279ff5).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #175      +/-   ##
==========================================
+ Coverage   87.40%   87.44%   +0.03%     
==========================================
  Files        1024     1024              
  Lines       33905    33905              
  Branches     2870     2870              
==========================================
+ Hits        29635    29647      +12     
+ Misses       3391     3383       -8     
+ Partials      879      875       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blehnen blehnen merged commit 47cb82c into master Jul 3, 2026
6 checks passed
@blehnen blehnen deleted the phase-5-dashboard-api-tests branch July 3, 2026 21:30
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