Skip to content

test: add SDK-level tests resolving MediatR handlers from a request against a real headless solution and PSI - #122

Merged
kzryzstof merged 18 commits into
mainfrom
features/support-sdk-tests
Sep 7, 2026
Merged

kzryzstof merged 18 commits into
mainfrom
features/support-sdk-tests

Conversation

@kzryzstof

@kzryzstof kzryzstof commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The plugin's handler resolution ran only against a live IDE — the existing suite covered the
"create handler" context action via gold files, but nothing exercised the lookup that answers
"given this request, where is its handler?". This adds component tests for that path, driving
the real ReSharper test framework so the resolution runs against restored MediatR assemblies
and genuine PSI caches rather than mocks.

Changes

  • Add MediatorHandlerLookupTests, deriving from BaseTestWithSingleProject, which commits
    documents, takes a read lock, locates a type declaration's name token, and asserts the
    handlers LibraryAdaptor.FindHandlers resolves for it.
  • Cover five cases: a handler declared in a separate file, an IRequest command with no
    response, a notification with two handlers, a request with no handler, and a type that is
    not a request.
  • Add six test data files under test/data/MediatorHandlerLookupTests/. These assert the
    lookup result directly, so no {caret} markers or .gold files are involved.
  • Add Microsoft.NET.Test.Sdk to the test project. Without it dotnet test discovered no
    tests and exited 0, so the existing suite never ran.
  • Add InternalsVisibleTo on the plugin assembly so the internal LibraryAdaptor is
    reachable from tests.
  • Move the test project to the Octelys.MediatorPlugin.Tests namespace and assembly name.

Reviewer note: these tests are unrun. The project targets net472 and the ReSharper test
framework needs Mono or Windows, so dotnet test cannot execute them on macOS or on the
current ubuntu-latest CI job — discovery reaches VSTest and stops at a missing Mono host.
They need a Windows run to confirm they pass. CI is not wired up in this PR.

Related

  • No ticket — this work was tracked outside Jira by request.

Generated by describe-pr skill v1.1.0

Exercise the plugin against a real headless solution: the ReSharper test
framework restores MediatR, builds the PSI caches, and LibraryAdaptor
resolves handlers the same way it does in the IDE.

Covers a handler declared in a separate file, a command without a
response, a notification with two handlers, a request with no handler,
and a type that is not a request at all.

Add Microsoft.NET.Test.Sdk so dotnet test discovers the project; without
it VSTest found no tests and exited 0. Expose plugin internals to the
test assembly so LibraryAdaptor is reachable.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
@kzryzstof kzryzstof changed the title test: add SDK-level handler lookup tests test: add SDK-level tests resolving MediatR handlers from a request against a real headless solution and PSI Sep 5, 2026
kzryzstof and others added 6 commits September 5, 2026 12:09
The ReSharper test framework targets net472, so the tests cannot execute
on the ubuntu runner the build job uses. Add a separate windows-latest
job that runs the test project directly.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
VSTest has no built-in 'GitHubActions' logger, so the test run failed
before executing a single test.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
The adapter the ReSharper SDK drops in the output directory cannot be
loaded by VSTest, so discovery found nothing and the job passed without
executing a single test. Reference NUnit3TestAdapter directly, and add a
trx-based guard so an empty run can never report green again.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
The SDK's copy in the output directory shadows it and fails to load, so
discovery found no tests.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
The adapter lives in the NuGet cache, which dotnet test only populates
once it runs, so the existence check fired too early.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
The attribute pulls in a JetBrains-hosted data package that is no longer
resolvable, failing fixture setup. The lookup data does not need it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
@kzryzstof
kzryzstof marked this pull request as draft September 5, 2026 16:33
kzryzstof and others added 11 commits September 5, 2026 12:35
The attribute was not the cause: fixture setup fails identically without
it, and the pre-existing suite fails the same way.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
- Mark all test handler classes as `internal` for stricter visibility.
- Add `[TestNetCoreLatest]` to `MediatorHandlerLookupTests` to replace the default framework, ensuring compatibility with test dependencies.
- Include a new `AGENTS.md` file summarizing the project structure, conventions, and build/test guidelines.
- Introduced `LookupTestBase`, a reusable base class for testing handler resolution across various scenarios.
- Added MediatR and Mediator-specific test classes to validate handler lookups for requests and notifications.
- Implemented validation for cases with multiple handlers, no handlers, nested handlers, and custom request types.
- Included test solution files and directories to simulate realistic conditions.
- Updated `[TestPackages]` attribute in `MediatRRequestsTests` to include MediatR versions `13.1.0` and `14.2.0`.
… load

- Added `TestSolutionFiles` to dynamically enumerate all .cs files in the test solution for MediatR and Mediator libraries.
- Updated tests to use `TestSolutionFiles` for cleaner, reusable file references.
- Improved `FindDeclarationIdentifier` to handle both fully qualified and short type names with enhanced validation.
- Refined test scenarios to streamline handler and request resolution logic.
- Updated `[MediatRTestPackages]` attribute to exclude older MediatR versions (V12, V13).
- Fixed class name typo from `MediatrCreateHandlrContextActionTests` to `MediatRCreateHandlrContextActionTests` for consistency.
- Replaced `[MediatRTestPackages]` with version-specific attributes (`[MediatRV12TestPackages]`, `[MediatRV13TestPackages]`, `[MediatRV14TestPackages]`).
- Refactored test base classes (`MediatRNotificationsTestsBase`, `MediatRRequestsTestsBase`, and `MediatRCreateHandlrContextActionTestsBase`) for improved reusability.
- Added version-specific test classes for Notifications, Requests, and CreateHandlrContextAction to separately validate behavior for MediatR versions V12, V13, and V14
- Replaced `[MediatorTestPackages]` with `[MediatorV3TestPackages]` for precision.
- Refactored test base classes (`MediatorNotificationsTestsBase`, `MediatorRequestsTestsBase`) to abstract shared logic.
- Added version-specific test classes (`MediatorNotificationsTestsV3`, `MediatorRequestsTestsV3`) to handle Mediator V3 testing separately.
- Deleted obsolete test data files from `MediatorHandlerLookupTests` (`NotARequest.cs`, `OrphanQuery.cs`, `SomeCommand.cs`, `SomeQuery.cs`, `SomeQueryHandler.cs`, `SomethingHappened.cs`).
- Simplified the test suite by cleaning up unused or irrelevant test artifacts.
@kzryzstof
kzryzstof marked this pull request as ready for review September 7, 2026 15:13
@kzryzstof
kzryzstof merged commit a781ad8 into main Sep 7, 2026
2 checks passed
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