From dfea75b26933b59a65c8edcad23fac354c7f70e0 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Sat, 5 Sep 2026 12:02:18 -0400 Subject: [PATCH 01/18] test: add SDK-level handler lookup tests 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 Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry --- .../MediatorHandlerLookupTests.cs | 159 ++++++++++++++++++ .../MediatorPlugin.Tests.csproj | 4 +- .../MediatrCreateHandlrContextActionTests.cs | 2 +- .../MediatorPlugin.Tests/TestEnvironment.cs | 2 +- .../MediatorHandlerLookupTests/NotARequest.cs | 5 + .../MediatorHandlerLookupTests/OrphanQuery.cs | 11 ++ .../MediatorHandlerLookupTests/SomeCommand.cs | 17 ++ .../MediatorHandlerLookupTests/SomeQuery.cs | 11 ++ .../SomeQueryHandler.cs | 13 ++ .../SomethingHappened.cs | 25 +++ .../MediatorPlugin/InternalsVisibleTo.cs | 3 + 11 files changed, 249 insertions(+), 3 deletions(-) create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/NotARequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/OrphanQuery.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeCommand.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQuery.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQueryHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomethingHappened.cs create mode 100644 src/dotnet/MediatorPlugin/InternalsVisibleTo.cs diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs new file mode 100644 index 0000000..3683be8 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs @@ -0,0 +1,159 @@ +using System.Collections.Generic; +using System.Linq; +using JetBrains.Lifetimes; +using JetBrains.ProjectModel; +using JetBrains.ReSharper.Psi; +using JetBrains.ReSharper.Psi.CSharp.Tree; +using JetBrains.ReSharper.Psi.Files; +using JetBrains.ReSharper.Psi.Tree; +using JetBrains.ReSharper.Resources.Shell; +using JetBrains.ReSharper.TestFramework; +using NUnit.Framework; +using ReSharper.MediatorPlugin.Services.Libraries; + +namespace Octelys.MediatorPlugin.Tests; + +/// +/// Exercises the handler lookup against a real solution: the framework restores MediatR, +/// builds the PSI caches, and the plugin resolves handlers the same way it does in the IDE. +/// +[TestPackages("MediatR/12.1.0")] +[TestReferences("System.Runtime")] +public class MediatorHandlerLookupTests : BaseTestWithSingleProject +{ + private string _requestTypeName; + private string[] _expectedHandlerNames; + + protected override string RelativeTestDataPath => nameof(MediatorHandlerLookupTests); + + [Test] + public void FindsHandlerDeclaredInAnotherFile() + { + AssertHandlersFor + ( + "SomeQuery", + ["SomeQueryHandler"], + "SomeQuery.cs", "SomeQueryHandler.cs" + ); + } + + [Test] + public void FindsHandlerForCommandWithoutResponse() + { + AssertHandlersFor + ( + "SomeCommand", + ["SomeCommandHandler"], + "SomeCommand.cs" + ); + } + + [Test] + public void FindsEveryHandlerOfANotification() + { + AssertHandlersFor + ( + "SomethingHappened", + ["AuditSomethingHappenedHandler", "NotifySomethingHappenedHandler"], + "SomethingHappened.cs" + ); + } + + [Test] + public void FindsNoHandlerWhenTheRequestHasNone() + { + AssertHandlersFor + ( + "OrphanQuery", + [], + "OrphanQuery.cs" + ); + } + + [Test] + public void FindsNoHandlerWhenTheTypeIsNotARequest() + { + AssertHandlersFor + ( + "NotARequest", + [], + "NotARequest.cs" + ); + } + + protected override void DoTest(Lifetime lifetime, ISolution solution) + { + solution.GetPsiServices().Files.CommitAllDocuments(); + + using (ReadLockCookie.Create()) + { + IIdentifier requestIdentifier = FindDeclarationIdentifier(solution, _requestTypeName); + + IEnumerable handlers = new LibraryAdaptor().FindHandlers(requestIdentifier); + + string[] handlerNames = handlers + .Select(handler => handler.ShortName) + .OrderBy(name => name) + .ToArray(); + + Assert.That(handlerNames, Is.EqualTo(_expectedHandlerNames.OrderBy(name => name).ToArray())); + } + } + + private void AssertHandlersFor + ( + string requestTypeName, + string[] expectedHandlerNames, + params string[] fileNames + ) + { + _requestTypeName = requestTypeName; + _expectedHandlerNames = expectedHandlerNames; + + DoTestSolution(fileNames); + } + + /// + /// Returns the name token of the type declaration, which is the node the plugin receives + /// when the caret sits on a request in the editor. + /// + private static IIdentifier FindDeclarationIdentifier + ( + ISolution solution, + string typeName + ) + { + IIdentifier identifier = EnumerateIdentifiers(solution) + .FirstOrDefault + ( + candidate => candidate.Name == typeName && candidate.Parent is IClassLikeDeclaration + ); + + Assert.That(identifier, Is.Not.Null, $"No declaration of '{typeName}' was found in the test solution."); + + return identifier; + } + + private static IEnumerable EnumerateIdentifiers + ( + ISolution solution + ) + { + foreach (IProject project in solution.GetAllProjects()) + foreach (IProjectFile projectFile in project.GetAllProjectFiles(_ => true)) + { + IPsiSourceFile sourceFile = projectFile.ToSourceFile(); + + if (sourceFile is null) + continue; + + IFile psiFile = sourceFile.GetPrimaryPsiFile(); + + if (psiFile is null) + continue; + + foreach (IIdentifier identifier in psiFile.Descendants().ToEnumerable()) + yield return identifier; + } + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj index 87015bf..f024748 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj +++ b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj @@ -4,11 +4,13 @@ net472 false latest - MediatorPlugin.Tests + Octelys.MediatorPlugin.Tests + Octelys.MediatorPlugin.Tests + diff --git a/src/dotnet/MediatorPlugin.Tests/MediatrCreateHandlrContextActionTests.cs b/src/dotnet/MediatorPlugin.Tests/MediatrCreateHandlrContextActionTests.cs index 947793d..62036b8 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatrCreateHandlrContextActionTests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatrCreateHandlrContextActionTests.cs @@ -3,7 +3,7 @@ using NUnit.Framework; using ReSharper.MediatorPlugin.Actions; -namespace NoSuchCompany.MediatrPlugin.Tests; +namespace Octelys.MediatorPlugin.Tests; [TestPackages("MediatR/12.1.0")] [TestReferences("System.Runtime")] // needed for IReadOnlyCollection type diff --git a/src/dotnet/MediatorPlugin.Tests/TestEnvironment.cs b/src/dotnet/MediatorPlugin.Tests/TestEnvironment.cs index 111a69f..a53133f 100644 --- a/src/dotnet/MediatorPlugin.Tests/TestEnvironment.cs +++ b/src/dotnet/MediatorPlugin.Tests/TestEnvironment.cs @@ -10,7 +10,7 @@ [assembly: Apartment(ApartmentState.STA)] -namespace NoSuchCompany.MediatrPlugin.Tests; +namespace Octelys.MediatorPlugin.Tests; [ZoneDefinition] public class ContextActionsTestEnvironmentZone : ITestsEnvZone, IRequire, IRequire diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/NotARequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/NotARequest.cs new file mode 100644 index 0000000..bbe3582 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/NotARequest.cs @@ -0,0 +1,5 @@ +namespace ClassLibrary1; + +public class NotARequest +{ +} diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/OrphanQuery.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/OrphanQuery.cs new file mode 100644 index 0000000..1b68451 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/OrphanQuery.cs @@ -0,0 +1,11 @@ +using MediatR; + +namespace ClassLibrary1; + +public class OrphanDto +{ +} + +public class OrphanQuery : IRequest +{ +} diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeCommand.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeCommand.cs new file mode 100644 index 0000000..ac40b30 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeCommand.cs @@ -0,0 +1,17 @@ +using System.Threading; +using System.Threading.Tasks; +using MediatR; + +namespace ClassLibrary1; + +public class SomeCommand : IRequest +{ +} + +public class SomeCommandHandler : IRequestHandler +{ + public Task Handle(SomeCommand request, CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQuery.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQuery.cs new file mode 100644 index 0000000..2321a47 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQuery.cs @@ -0,0 +1,11 @@ +using MediatR; + +namespace ClassLibrary1; + +public class SomeDto +{ +} + +public class SomeQuery : IRequest +{ +} diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQueryHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQueryHandler.cs new file mode 100644 index 0000000..c7846cc --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQueryHandler.cs @@ -0,0 +1,13 @@ +using System.Threading; +using System.Threading.Tasks; +using MediatR; + +namespace ClassLibrary1; + +public class SomeQueryHandler : IRequestHandler +{ + public Task Handle(SomeQuery request, CancellationToken cancellationToken) + { + return Task.FromResult(new SomeDto()); + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomethingHappened.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomethingHappened.cs new file mode 100644 index 0000000..f5b787a --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomethingHappened.cs @@ -0,0 +1,25 @@ +using System.Threading; +using System.Threading.Tasks; +using MediatR; + +namespace ClassLibrary1; + +public class SomethingHappened : INotification +{ +} + +public class AuditSomethingHappenedHandler : INotificationHandler +{ + public Task Handle(SomethingHappened notification, CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} + +public class NotifySomethingHappenedHandler : INotificationHandler +{ + public Task Handle(SomethingHappened notification, CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} diff --git a/src/dotnet/MediatorPlugin/InternalsVisibleTo.cs b/src/dotnet/MediatorPlugin/InternalsVisibleTo.cs new file mode 100644 index 0000000..f6e5c38 --- /dev/null +++ b/src/dotnet/MediatorPlugin/InternalsVisibleTo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Octelys.MediatorPlugin.Tests")] From a29eae523f092d23f3d7b193c3e9bdd021ea65fb Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Sat, 5 Sep 2026 12:09:56 -0400 Subject: [PATCH 02/18] ci: run dotnet tests on a windows runner 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 Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry --- .github/workflows/cicd.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 2833606..b4c2ce2 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -19,6 +19,24 @@ on: description: 'Runner' jobs: + test: + name: test (dotnet) + # The ReSharper test framework targets net472 and needs the .NET Framework + # runtime, so these tests cannot run on the ubuntu runner used by `build`. + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: checkout + uses: actions/checkout@v7 + + - name: install .NET SDK + uses: actions/setup-dotnet@v6 + with: + dotnet-version: '9.x' + + - name: test + run: dotnet test src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj --logger GitHubActions + build: runs-on: ${{ inputs.runs_on || 'ubuntu-latest' }} steps: From bc6b2497f40cb8f603c483f5cdc49e838ef77c58 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Sat, 5 Sep 2026 12:13:14 -0400 Subject: [PATCH 03/18] ci: add GitHubActionsTestLogger so the logger resolves VSTest has no built-in 'GitHubActions' logger, so the test run failed before executing a single test. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry --- src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj index f024748..0ac1ddb 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj +++ b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj @@ -11,6 +11,7 @@ + From 6f22ae7adccb3b2769f9c6caf3fb460d5ebca6af Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Sat, 5 Sep 2026 12:17:24 -0400 Subject: [PATCH 04/18] ci: load a working NUnit adapter and fail on a zero-test run 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 Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry --- .github/workflows/cicd.yml | 13 ++++++++++++- .../MediatorPlugin.Tests.csproj | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index b4c2ce2..ba569ed 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -35,7 +35,18 @@ jobs: dotnet-version: '9.x' - name: test - run: dotnet test src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj --logger GitHubActions + run: dotnet test src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj --logger GitHubActions --logger "trx;LogFileName=results.trx" --results-directory ${{ github.workspace }}/testresults + + # VSTest exits 0 when it discovers nothing, so a broken adapter would + # otherwise report a green build that ran no tests at all. + - name: assert tests actually ran + shell: pwsh + run: | + $trx = Get-ChildItem "${{ github.workspace }}/testresults" -Filter *.trx -Recurse | Select-Object -First 1 + if (-not $trx) { throw "No .trx produced - the test run did not happen." } + $counters = ([xml](Get-Content $trx.FullName)).TestRun.ResultSummary.Counters + Write-Host "total=$($counters.total) executed=$($counters.executed) passed=$($counters.passed) failed=$($counters.failed)" + if ([int]$counters.executed -lt 1) { throw "No tests were executed." } build: runs-on: ${{ inputs.runs_on || 'ubuntu-latest' }} diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj index 0ac1ddb..18a1eba 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj +++ b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj @@ -12,6 +12,7 @@ + From 8799544a20e2faa6b66b41dad118ba74d3ce0715 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Sat, 5 Sep 2026 12:21:55 -0400 Subject: [PATCH 05/18] ci: point VSTest at the NUnit adapter from the package 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 Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry --- .github/workflows/cicd.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index ba569ed..f2415c6 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -34,8 +34,20 @@ jobs: with: dotnet-version: '9.x' + # The ReSharper SDK drops its own NUnit3.TestAdapter.dll into the output + # directory and it cannot be loaded by VSTest, shadowing the working one + # from the NUnit3TestAdapter package. Point VSTest straight at the latter. - name: test - run: dotnet test src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj --logger GitHubActions --logger "trx;LogFileName=results.trx" --results-directory ${{ github.workspace }}/testresults + shell: pwsh + run: | + $packages = if ($env:NUGET_PACKAGES) { $env:NUGET_PACKAGES } else { Join-Path $env:USERPROFILE ".nuget\packages" } + $adapter = Join-Path $packages "nunit3testadapter\4.6.0\build\net462" + if (-not (Test-Path $adapter)) { throw "NUnit adapter not found at $adapter" } + dotnet test src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj ` + --test-adapter-path $adapter ` + --logger GitHubActions ` + --logger "trx;LogFileName=results.trx" ` + --results-directory "${{ github.workspace }}/testresults" # VSTest exits 0 when it discovers nothing, so a broken adapter would # otherwise report a green build that ran no tests at all. From ec0d959b2fb738d9410500d5242894d34674ce17 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Sat, 5 Sep 2026 12:24:58 -0400 Subject: [PATCH 06/18] ci: restore before resolving the adapter path 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 Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry --- .github/workflows/cicd.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index f2415c6..623f85c 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -37,6 +37,9 @@ jobs: # The ReSharper SDK drops its own NUnit3.TestAdapter.dll into the output # directory and it cannot be loaded by VSTest, shadowing the working one # from the NUnit3TestAdapter package. Point VSTest straight at the latter. + - name: restore + run: dotnet restore src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj + - name: test shell: pwsh run: | @@ -47,6 +50,7 @@ jobs: --test-adapter-path $adapter ` --logger GitHubActions ` --logger "trx;LogFileName=results.trx" ` + --no-restore ` --results-directory "${{ github.workspace }}/testresults" # VSTest exits 0 when it discovers nothing, so a broken adapter would From 2ee3f1eb3ee2cbf417d5a760a96981f01add6d2c Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Sat, 5 Sep 2026 12:30:38 -0400 Subject: [PATCH 07/18] test: drop TestReferences from the lookup tests 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 Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry --- src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs index 3683be8..e168f79 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs @@ -18,7 +18,6 @@ namespace Octelys.MediatorPlugin.Tests; /// builds the PSI caches, and the plugin resolves handlers the same way it does in the IDE. /// [TestPackages("MediatR/12.1.0")] -[TestReferences("System.Runtime")] public class MediatorHandlerLookupTests : BaseTestWithSingleProject { private string _requestTypeName; From c08298e24fc0a2bb1cecce0a14e595946f711c1b Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Sat, 5 Sep 2026 12:35:20 -0400 Subject: [PATCH 08/18] Revert "test: drop TestReferences from the lookup tests" 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 Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry --- src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs index e168f79..3683be8 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs @@ -18,6 +18,7 @@ namespace Octelys.MediatorPlugin.Tests; /// builds the PSI caches, and the plugin resolves handlers the same way it does in the IDE. /// [TestPackages("MediatR/12.1.0")] +[TestReferences("System.Runtime")] public class MediatorHandlerLookupTests : BaseTestWithSingleProject { private string _requestTypeName; From 86667b1257214c31fbdc76127084accaebcf011b Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Mon, 7 Sep 2026 09:03:54 -0400 Subject: [PATCH 09/18] test: update tests for handler visibility and framework compatibility - 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. --- AGENTS.md | 48 +++++++++++++++++++ .../MediatorHandlerLookupTests.cs | 3 ++ .../TestCommand.cs.gold | 2 +- .../TestCustomBaseClassQuery.cs.gold | 2 +- ...estedBaseClassMultipleGenericQuery.cs.gold | 2 +- .../TestCustomNestedBaseClassQuery.cs.gold | 2 +- .../TestSimpleQuery.cs.gold | 2 +- 7 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..06f4544 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,48 @@ +# AGENTS.md + +ReSharper + Rider plugin for MediatR/mediator codebases. Two halves that ship together: +a .NET backend (`src/dotnet`) and a Kotlin/IntelliJ frontend (`src/rider`), wired over a +generated protocol (`protocol/`). + +## Layout + +| Path | What it is | +| --- | --- | +| `src/dotnet/MediatorPlugin` | Backend: actions, navigations, diagnostics, services | +| `src/dotnet/MediatorPlugin.Tests` | Backend tests (ReSharper test framework) | +| `src/rider/main` | Kotlin frontend + `META-INF/plugin.xml` | +| `protocol` | RD protocol model shared by both halves | +| `test-solution` | Sample solution the tests and manual runs operate on | + +## Build and test + +```bash +dotnet test src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj +./gradlew :prepareSandbox -PPluginVersion= # full plugin build +``` + +- **Everything targets `net472`.** The ReSharper test framework needs the .NET Framework + runtime, so the backend tests only run on Windows — CI runs them on `windows-latest` + while the Gradle build runs on Ubuntu. Don't "fix" a test failure that is really a + platform mismatch. +- `MediatorPlugin` has **two project files** in the same directory: + `MediatorPlugin.csproj` (ReSharper) and `MediatorPlugin.Rider.csproj` (Rider). A change + to one usually belongs in both; check before assuming a single build covers you. +- `PluginVersion` in `gradle.properties` and the `` in `plugin.xml` are + `_PLACEHOLDER_` on purpose. CI stamps them via `update-version.sh`. Never commit a + concrete version there. + +## Conventions + +- Branches: `features/` or `bugs/`, PRs target `main`. +- Tests must follow [docs/unit-test-guidelines.md](docs/unit-test-guidelines.md): + `MethodName_ScenarioInPresentTense_ExpectedResult` naming, AAA section comments, and + one call per line in fluent chains. Read it before writing or editing a test class. + +## File editing + +- Modify files with your editor/patch tools (str-replace, create-file, apply-patch). +- Do not write files through the shell: no heredocs (`cat > file <<'EOF'`), no `echo >`, + `printf >`, `tee`, or `sed -i`. Shell redirection into tracked files is prohibited. +- The shell is for read-only inspection (`cat`, `grep`, `ls`, `find`) and for running + builds, tests, and git commands. diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs index 3683be8..65f8802 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs @@ -17,6 +17,9 @@ namespace Octelys.MediatorPlugin.Tests; /// Exercises the handler lookup against a real solution: the framework restores MediatR, /// builds the PSI caches, and the plugin resolves handlers the same way it does in the IDE. /// +// BaseTestWithSolution defaults to [TestNetFramework35], whose platform package is not on +// nuget.org; the context action tests get their framework from CSharpContextActionExecuteTestBase. +[TestNetCoreLatest] [TestPackages("MediatR/12.1.0")] [TestReferences("System.Runtime")] public class MediatorHandlerLookupTests : BaseTestWithSingleProject diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCommand.cs.gold b/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCommand.cs.gold index 9b83a42..26ded7c 100644 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCommand.cs.gold +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCommand.cs.gold @@ -5,7 +5,7 @@ public class SomeCommand : IRequest { } -public class SomeCommandHandler : IRequestHandler +internal class SomeCommandHandler : IRequestHandler { public Task Handle(SomeCommand request, CancellationToken cancellationToken) { diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomBaseClassQuery.cs.gold b/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomBaseClassQuery.cs.gold index c71718d..759ba34 100644 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomBaseClassQuery.cs.gold +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomBaseClassQuery.cs.gold @@ -11,7 +11,7 @@ public class SomeQuery : BaseQuery { } -public class SomeQueryHandler : IRequestHandler +internal class SomeQueryHandler : IRequestHandler { public Task Handle(SomeQuery request, CancellationToken cancellationToken) { diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomNestedBaseClassMultipleGenericQuery.cs.gold b/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomNestedBaseClassMultipleGenericQuery.cs.gold index 92b4a75..56caec1 100644 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomNestedBaseClassMultipleGenericQuery.cs.gold +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomNestedBaseClassMultipleGenericQuery.cs.gold @@ -18,7 +18,7 @@ public class SomeQuery : GetItemsQuery { } -public class SomeQueryHandler : IRequestHandler> +internal class SomeQueryHandler : IRequestHandler> { public Task> Handle(SomeQuery request, CancellationToken cancellationToken) { diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomNestedBaseClassQuery.cs.gold b/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomNestedBaseClassQuery.cs.gold index 2e1a551..d761127 100644 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomNestedBaseClassQuery.cs.gold +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestCustomNestedBaseClassQuery.cs.gold @@ -17,7 +17,7 @@ public class SomeQuery : GetItemsQuery { } -public class SomeQueryHandler : IRequestHandler> +internal class SomeQueryHandler : IRequestHandler> { public Task> Handle(SomeQuery request, CancellationToken cancellationToken) { diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestSimpleQuery.cs.gold b/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestSimpleQuery.cs.gold index 0075aee..2f4c812 100644 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestSimpleQuery.cs.gold +++ b/src/dotnet/MediatorPlugin.Tests/test/data/MediatrCreateHandlrContextActionTests/TestSimpleQuery.cs.gold @@ -7,7 +7,7 @@ public class SomeQuery : IRequest { } -public class SomeQueryHandler : IRequestHandler +internal class SomeQueryHandler : IRequestHandler { public Task Handle(SomeQuery request, CancellationToken cancellationToken) { From f854e6b3aa10e88f878da87e008e1b735c50cef3 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Mon, 7 Sep 2026 09:36:56 -0400 Subject: [PATCH 10/18] test: add comprehensive handler resolution tests - 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. --- .../MediatorPlugin.Tests/LookupTestBase.cs | 124 ++++++++++++++++++ .../MediatR.Notifications.Tests.cs | 22 ++++ .../MediatR.Requests.Tests.cs | 118 +++++++++++++++++ .../Mediator.Notifications.Tests.cs | 22 ++++ .../Mediator.Requests.Tests.cs | 22 ++++ .../MediatorHandlerLookupTests.cs | 99 +++++++++----- .../MediatorPlugin.Tests.csproj | 10 ++ .../test/data/TestSolution/Entities/Dto.cs | 6 + .../Entities/GetEntityResponse.cs | 7 + .../OtherNamespace/GetEntityResponse.cs | 7 + .../Entities/ReadonlyRecordStructResponse.cs | 3 + .../MediatR/Handlers/BaseRequestHandler.cs | 17 +++ .../MediatR/Handlers/CustomClassHandler.cs | 15 +++ .../MediatR/Handlers/CustomRecordHandler.cs | 15 +++ .../MediatR/Handlers/DuplicateHandler.cs | 15 +++ .../FirstCustomNotificationHandler.cs | 15 +++ .../MediatR/Handlers/GetEntityHandler.cs | 16 +++ .../MediatR/Handlers/ISharedCommandHandler.cs | 7 + .../OtherNamespace/GetEntityHandler.cs | 16 +++ .../MediatR/Handlers/OuterClassHandler.cs | 21 +++ .../Handlers/ReadonlyRecordStructHandler.cs | 15 +++ .../SecondCustomNotificationHandler.cs | 15 +++ .../MediatR/Handlers/StartStreamingHandler.cs | 16 +++ .../Handlers/TriggerDeletionHandler.cs | 16 +++ .../MediatR/Handlers/XCommandHandler.cs | 20 +++ .../Notifications/CustomNotification.cs | 9 ++ .../MediatR/Requests/CustomClassRequest.cs | 7 + .../MediatR/Requests/CustomRecordRequest.cs | 7 + .../MediatR/Requests/GetEntityRequest.cs | 9 ++ .../MediatR/Requests/ICustomRequest.cs | 8 ++ .../MediatR/Requests/InnerClassRequest.cs | 9 ++ .../MediatR/Requests/NewRequest.cs | 9 ++ .../Requests/OtherNamespace/CustomRequest.cs | 7 + .../OtherNamespace/GetEntityRequest.cs | 9 ++ .../Requests/OtherNamespace/ICustomRequest.cs | 9 ++ .../MediatR/Requests/OtherRequest.cs | 7 + .../Requests/ReadonlyRecordStructRequest.cs | 6 + .../MediatR/Requests/StartStreamingRequest.cs | 9 ++ .../Requests/TriggerDeletionRequest.cs | 9 ++ .../MediatR/Requests/XCommandRequest.cs | 10 ++ .../Mediator/Handlers/NewMediatorHandler.cs | 16 +++ .../NewMediatorNotificationHandler.cs | 16 +++ .../OtherMediatorNotificationHandler.cs | 16 +++ .../Notifications/NewMediatorNotification.cs | 10 ++ .../Mediator/Requests/NewMediatorRequest.cs | 10 ++ 45 files changed, 815 insertions(+), 36 deletions(-) create mode 100644 src/dotnet/MediatorPlugin.Tests/LookupTestBase.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/Dto.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/GetEntityResponse.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/OtherNamespace/GetEntityResponse.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/ReadonlyRecordStructResponse.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/BaseRequestHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/CustomClassHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/CustomRecordHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/DuplicateHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/FirstCustomNotificationHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/GetEntityHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/ISharedCommandHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/OtherNamespace/GetEntityHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/OuterClassHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/ReadonlyRecordStructHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/SecondCustomNotificationHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/StartStreamingHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/TriggerDeletionHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/XCommandHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Notifications/CustomNotification.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/CustomClassRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/CustomRecordRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/GetEntityRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/ICustomRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/InnerClassRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/NewRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/CustomRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/GetEntityRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/ICustomRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/ReadonlyRecordStructRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/StartStreamingRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/TriggerDeletionRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/XCommandRequest.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/NewMediatorHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/NewMediatorNotificationHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/OtherMediatorNotificationHandler.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Notifications/NewMediatorNotification.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Requests/NewMediatorRequest.cs diff --git a/src/dotnet/MediatorPlugin.Tests/LookupTestBase.cs b/src/dotnet/MediatorPlugin.Tests/LookupTestBase.cs new file mode 100644 index 0000000..e522057 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/LookupTestBase.cs @@ -0,0 +1,124 @@ +using System.Collections.Generic; +using System.Linq; +using JetBrains.Lifetimes; +using JetBrains.ProjectModel; +using JetBrains.ReSharper.Psi; +using JetBrains.ReSharper.Psi.CSharp.Tree; +using JetBrains.ReSharper.Psi.Files; +using JetBrains.ReSharper.Psi.Tree; +using JetBrains.ReSharper.Resources.Shell; +using JetBrains.ReSharper.TestFramework; +using NUnit.Framework; +using ReSharper.MediatorPlugin.Services.Libraries; + +namespace Octelys.MediatorPlugin.Tests; + +/// +/// Shared plumbing for tests that load a small test solution and assert which handlers the +/// plugin resolves for a given request or notification type. Test data lives under +/// test/data/TestSolution, organized per library (MediatR, Mediator) and kind (Requests, +/// Notifications, Handlers, Entities). +/// +public abstract class LookupTestBase : BaseTestWithSingleProject +{ + private string _requestTypeName; + private string[] _expectedHandlerNames; + + protected override string RelativeTestDataPath => "TestSolution"; + + /// + /// Runs inside the loaded test solution: the framework calls this once the project of the + /// current test has been restored and its PSI caches are ready. + /// + protected override void DoTest + ( + Lifetime lifetime, + ISolution solution + ) + { + solution.GetPsiServices().Files.CommitAllDocuments(); + + using (ReadLockCookie.Create()) + { + IIdentifier requestIdentifier = FindDeclarationIdentifier(solution, _requestTypeName); + + IEnumerable handlers = new LibraryAdaptor().FindHandlers(requestIdentifier); + + string[] handlerNames = handlers + .Select(handler => handler.ShortName) + .OrderBy(name => name) + .ToArray(); + + Assert.That(handlerNames, Is.EqualTo(_expectedHandlerNames.OrderBy(name => name).ToArray())); + } + } + + /// + /// Loads the given files as a test solution and asserts that the request or notification + /// resolves to exactly the expected handlers; the lookup itself runs in . + /// + protected void AssertHandlersFor + ( + string requestTypeName, + string[] expectedHandlerNames, + params string[] fileNames + ) + { + _requestTypeName = requestTypeName; + _expectedHandlerNames = expectedHandlerNames; + + DoTestSolution(fileNames); + } + + /// + /// Returns the name token of the type declaration, which is the node the plugin receives + /// when the caret sits on a request in the editor. + /// + private static IIdentifier FindDeclarationIdentifier + ( + ISolution solution, + string typeName + ) + { + IIdentifier identifier = EnumerateIdentifiers(solution) + .FirstOrDefault + ( + candidate => candidate.Name == typeName && candidate.Parent is IClassLikeDeclaration + ); + + Assert.That(identifier, Is.Not.Null, $"No declaration of '{typeName}' was found in the test solution."); + + return identifier; + } + + private static IEnumerable EnumerateIdentifiers + ( + ISolution solution + ) + { + foreach (IProject project in solution.GetAllProjects()) + { + foreach (IProjectFile projectFile in project.GetAllProjectFiles(_ => true)) + { + IPsiSourceFile sourceFile = projectFile.ToSourceFile(); + + if (sourceFile is null) + { + continue; + } + + IFile psiFile = sourceFile.GetPrimaryPsiFile(); + + if (psiFile is null) + { + continue; + } + + foreach (IIdentifier identifier in psiFile.Descendants().ToEnumerable()) + { + yield return identifier; + } + } + } + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs new file mode 100644 index 0000000..4bc9154 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs @@ -0,0 +1,22 @@ +using JetBrains.ReSharper.TestFramework; +using NUnit.Framework; + +namespace Octelys.MediatorPlugin.Tests; + +[TestNetCoreLatest] +[TestPackages("MediatR/12.5.0")] +[TestReferences("System.Runtime")] +public class MediatRNotificationsTests : LookupTestBase +{ + [Test] + public void FindHandlers_NotificationHasMultipleHandlers_EveryHandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "CustomNotification", + ["FirstCustomNotificationHandler", "SecondCustomNotificationHandler"], + "MediatR/Notifications/CustomNotification.cs", "MediatR/Handlers/FirstCustomNotificationHandler.cs", "MediatR/Handlers/SecondCustomNotificationHandler.cs" + ); + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs new file mode 100644 index 0000000..53cbd50 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs @@ -0,0 +1,118 @@ +using JetBrains.ReSharper.TestFramework; +using NUnit.Framework; + +namespace Octelys.MediatorPlugin.Tests; + +[TestNetCoreLatest] +[TestPackages("MediatR/12.5.0")] +[TestReferences("System.Runtime")] +public class MediatRRequestsTests : LookupTestBase +{ + [Test] + public void FindHandlers_HandlerDeclaredInSameNamespace_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "GetEntityRequest", + ["GetEntityHandler"], + "MediatR/Requests/GetEntityRequest.cs", "MediatR/Handlers/GetEntityHandler.cs", "Entities/GetEntityResponse.cs" + ); + } + + [Test] + public void FindHandlers_RequestAndHandlerAreInACustomNamespace_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "GetEntityRequest", + ["GetEntityHandler"], + "MediatR/Requests/OtherNamespace/GetEntityRequest.cs", "MediatR/Handlers/OtherNamespace/GetEntityHandler.cs", "Entities/OtherNamespace/GetEntityResponse.cs" + ); + } + + [Test] + public void FindHandlers_RequestImplementsCustomBaseRequestInterface_EveryHandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "CustomClassRequest", + ["CustomClassHandler", "DuplicateHandler"], + "MediatR/Requests/ICustomRequest.cs", "MediatR/Requests/CustomClassRequest.cs", "MediatR/Handlers/CustomClassHandler.cs", "MediatR/Handlers/DuplicateHandler.cs" + ); + } + + [Test] + public void FindHandlers_RequestIsARecord_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "CustomRecordRequest", + ["CustomRecordHandler"], + "MediatR/Requests/ICustomRequest.cs", "MediatR/Requests/CustomRecordRequest.cs", "MediatR/Handlers/CustomRecordHandler.cs" + ); + } + + [Test] + public void FindHandlers_HandlerIsNestedInsideOuterClasses_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "InnerClassRequest", + ["InnerClassHandler"], + "MediatR/Requests/InnerClassRequest.cs", "MediatR/Handlers/OuterClassHandler.cs" + ); + } + + [Test] + public void FindHandlers_HandlerInheritsFromAbstractBaseClass_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "OtherRequest", + ["BaseRequestHandler"], + "MediatR/Requests/ICustomRequest.cs", "MediatR/Requests/OtherRequest.cs", "MediatR/Requests/NewRequest.cs", "MediatR/Handlers/BaseRequestHandler.cs" + ); + } + + [Test] + public void FindHandlers_RequestHasNoHandler_NoHandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "NewRequest", + [], + "MediatR/Requests/NewRequest.cs" + ); + } + + [Test] + public void FindHandlers_RequestIsAReadonlyRecord_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "ReadonlyRecordStructRequest", + ["ReadonlyRecordStructHandler"], + "MediatR/Requests/ReadonlyRecordStructRequest.cs", "MediatR/Handlers/ReadonlyRecordStructHandler.cs", "Entities/ReadonlyRecordStructResponse.cs" + ); + } + + [Test] + public void FindHandlers_HandlerImplementsSharedGenericHandlerInterface_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "XCommandRequest", + ["XCommandHandler"], + "MediatR/Requests/XCommandRequest.cs", "MediatR/Handlers/XCommandHandler.cs", "MediatR/Handlers/ISharedCommandHandler.cs", "Entities/Dto.cs" + ); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs new file mode 100644 index 0000000..0b59a64 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs @@ -0,0 +1,22 @@ +using JetBrains.ReSharper.TestFramework; +using NUnit.Framework; + +namespace Octelys.MediatorPlugin.Tests; + +[TestNetCoreLatest] +[TestPackages("Mediator.Abstractions/3.0.1")] +[TestReferences("System.Runtime")] +public class MediatorNotificationsTests : LookupTestBase +{ + [Test] + public void FindHandlers_NotificationHasMultipleHandlers_EveryHandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "NewMediatorNotification", + ["NewMediatorNotificationHandler", "MediatorNotificationHandler"], + "Mediator/Notifications/NewMediatorNotification.cs", "Mediator/Handlers/NewMediatorNotificationHandler.cs", "Mediator/Handlers/OtherMediatorNotificationHandler.cs", "Entities/Dto.cs" + ); + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs new file mode 100644 index 0000000..24c8fed --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs @@ -0,0 +1,22 @@ +using JetBrains.ReSharper.TestFramework; +using NUnit.Framework; + +namespace Octelys.MediatorPlugin.Tests; + +[TestNetCoreLatest] +[TestPackages("Mediator.Abstractions/3.0.1")] +[TestReferences("System.Runtime")] +public class MediatorRequestsTests : LookupTestBase +{ + [Test] + public void FindHandlers_RequestImplementsMultipleRequestInterfaces_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "NewMediatorRequest", + ["NewMediatorHandler"], + "Mediator/Requests/NewMediatorRequest.cs", "Mediator/Handlers/NewMediatorHandler.cs", "Entities/Dto.cs" + ); + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs index 65f8802..e3ca4dc 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs @@ -29,9 +29,37 @@ public class MediatorHandlerLookupTests : BaseTestWithSingleProject protected override string RelativeTestDataPath => nameof(MediatorHandlerLookupTests); + /// + /// Runs inside the loaded test solution: the framework calls this once the project of the + /// current test has been restored and its PSI caches are ready. + /// + protected override void DoTest + ( + Lifetime lifetime, + ISolution solution + ) + { + solution.GetPsiServices().Files.CommitAllDocuments(); + + using (ReadLockCookie.Create()) + { + IIdentifier requestIdentifier = FindDeclarationIdentifier(solution, _requestTypeName); + + IEnumerable handlers = new LibraryAdaptor().FindHandlers(requestIdentifier); + + string[] handlerNames = handlers + .Select(handler => handler.ShortName) + .OrderBy(name => name) + .ToArray(); + + Assert.That(handlerNames, Is.EqualTo(_expectedHandlerNames.OrderBy(name => name).ToArray())); + } + } + [Test] - public void FindsHandlerDeclaredInAnotherFile() + public void FindHandlers_HandlerIsDeclaredInAnotherFile_HandlerReturned() { + // Act & Assert. AssertHandlersFor ( "SomeQuery", @@ -41,8 +69,9 @@ public void FindsHandlerDeclaredInAnotherFile() } [Test] - public void FindsHandlerForCommandWithoutResponse() + public void FindHandlers_RequestIsACommandWithoutResponse_HandlerReturned() { + // Act & Assert. AssertHandlersFor ( "SomeCommand", @@ -52,8 +81,9 @@ public void FindsHandlerForCommandWithoutResponse() } [Test] - public void FindsEveryHandlerOfANotification() + public void FindHandlers_RequestIsANotification_EveryHandlerReturned() { + // Act & Assert. AssertHandlersFor ( "SomethingHappened", @@ -63,8 +93,9 @@ public void FindsEveryHandlerOfANotification() } [Test] - public void FindsNoHandlerWhenTheRequestHasNone() + public void FindHandlers_RequestHasNoHandler_NoHandlerReturned() { + // Act & Assert. AssertHandlersFor ( "OrphanQuery", @@ -74,8 +105,9 @@ public void FindsNoHandlerWhenTheRequestHasNone() } [Test] - public void FindsNoHandlerWhenTheTypeIsNotARequest() + public void FindHandlers_TypeIsNotARequest_NoHandlerReturned() { + // Act & Assert. AssertHandlersFor ( "NotARequest", @@ -84,25 +116,12 @@ public void FindsNoHandlerWhenTheTypeIsNotARequest() ); } - protected override void DoTest(Lifetime lifetime, ISolution solution) - { - solution.GetPsiServices().Files.CommitAllDocuments(); - - using (ReadLockCookie.Create()) - { - IIdentifier requestIdentifier = FindDeclarationIdentifier(solution, _requestTypeName); - - IEnumerable handlers = new LibraryAdaptor().FindHandlers(requestIdentifier); - - string[] handlerNames = handlers - .Select(handler => handler.ShortName) - .OrderBy(name => name) - .ToArray(); - - Assert.That(handlerNames, Is.EqualTo(_expectedHandlerNames.OrderBy(name => name).ToArray())); - } - } + // Helper methods. + /// + /// Loads the given files as a test solution and asserts that the request resolves to exactly + /// the expected handlers; the lookup itself runs in . + /// private void AssertHandlersFor ( string requestTypeName, @@ -143,20 +162,28 @@ ISolution solution ) { foreach (IProject project in solution.GetAllProjects()) - foreach (IProjectFile projectFile in project.GetAllProjectFiles(_ => true)) { - IPsiSourceFile sourceFile = projectFile.ToSourceFile(); - - if (sourceFile is null) - continue; - - IFile psiFile = sourceFile.GetPrimaryPsiFile(); - - if (psiFile is null) - continue; - - foreach (IIdentifier identifier in psiFile.Descendants().ToEnumerable()) - yield return identifier; + foreach (IProjectFile projectFile in project.GetAllProjectFiles(_ => true)) + { + IPsiSourceFile sourceFile = projectFile.ToSourceFile(); + + if (sourceFile is null) + { + continue; + } + + IFile psiFile = sourceFile.GetPrimaryPsiFile(); + + if (psiFile is null) + { + continue; + } + + foreach (IIdentifier identifier in psiFile.Descendants().ToEnumerable()) + { + yield return identifier; + } + } } } } diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj index 18a1eba..07ec743 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj +++ b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj @@ -24,4 +24,14 @@ + + + + + + + + + + diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/Dto.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/Dto.cs new file mode 100644 index 0000000..b5ac828 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/Dto.cs @@ -0,0 +1,6 @@ +namespace DotNetCore6_Domain.Entities; + +public sealed class Dto +{ + +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/GetEntityResponse.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/GetEntityResponse.cs new file mode 100644 index 0000000..689662b --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/GetEntityResponse.cs @@ -0,0 +1,7 @@ +namespace Domain +{ + public sealed class GetEntityResponse + { + + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/OtherNamespace/GetEntityResponse.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/OtherNamespace/GetEntityResponse.cs new file mode 100644 index 0000000..8fb5fea --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/OtherNamespace/GetEntityResponse.cs @@ -0,0 +1,7 @@ +namespace Domain.OtherNamespace +{ + public sealed class GetEntityResponse + { + + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/ReadonlyRecordStructResponse.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/ReadonlyRecordStructResponse.cs new file mode 100644 index 0000000..d993cb1 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Entities/ReadonlyRecordStructResponse.cs @@ -0,0 +1,3 @@ +namespace DotNetCore6_Domain.MediatR.Requests; + +public readonly record struct MyResponse(string input); \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/BaseRequestHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/BaseRequestHandler.cs new file mode 100644 index 0000000..c39c246 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/BaseRequestHandler.cs @@ -0,0 +1,17 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.MediatR.Requests; +using MediatR; + +namespace DotNet6Core_Application.MediatR.Handlers; + +public abstract class BaseRequestHandler : IRequestHandler +{ + public Task Handle(OtherRequest request, CancellationToken cancellationToken) + { + NewRequest newRequest = new NewRequest(); + + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/CustomClassHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/CustomClassHandler.cs new file mode 100644 index 0000000..61bd8f2 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/CustomClassHandler.cs @@ -0,0 +1,15 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.MediatR.Requests; +using MediatR; + +namespace DotNet6Core_Application.MediatR.Handlers; + +public class CustomClassHandler : IRequestHandler +{ + public Task Handle(CustomClassRequest classRequest, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/CustomRecordHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/CustomRecordHandler.cs new file mode 100644 index 0000000..e214f1a --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/CustomRecordHandler.cs @@ -0,0 +1,15 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.MediatR.Requests; +using MediatR; + +namespace DotNet6Core_Application.MediatR.Handlers; + +public record CustomRecordHandler : IRequestHandler +{ + public Task Handle(CustomRecordRequest recordRequest, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/DuplicateHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/DuplicateHandler.cs new file mode 100644 index 0000000..c6c6abf --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/DuplicateHandler.cs @@ -0,0 +1,15 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.MediatR.Requests; +using MediatR; + +namespace DotNet6Core_Application.MediatR.Handlers; + +public class DuplicateHandler : IRequestHandler +{ + public Task Handle(CustomClassRequest classRequest, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/FirstCustomNotificationHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/FirstCustomNotificationHandler.cs new file mode 100644 index 0000000..e1a77c9 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/FirstCustomNotificationHandler.cs @@ -0,0 +1,15 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.MediatR.Notifications; +using MediatR; + +namespace DotNet6Core_Application.MediatR.Notifcations; + +internal sealed class FirstCustomNotificationHandler : INotificationHandler +{ + public Task Handle(CustomNotification notification, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/GetEntityHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/GetEntityHandler.cs new file mode 100644 index 0000000..58a5f09 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/GetEntityHandler.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Domain; +using MediatR; + +namespace Application +{ + internal sealed class GetEntityHandler : IRequestHandler + { + public Task Handle(GetEntityRequest request, CancellationToken cancellationToken) + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/ISharedCommandHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/ISharedCommandHandler.cs new file mode 100644 index 0000000..982cc91 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/ISharedCommandHandler.cs @@ -0,0 +1,7 @@ +using DotNetCore6_Domain.Entities; +using MediatR; + +namespace DotNetCore6_Domain.MediatR.Handlers; + +public interface ISharedCommandHandler : IRequestHandler> + where TRequest : IRequest>; diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/OtherNamespace/GetEntityHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/OtherNamespace/GetEntityHandler.cs new file mode 100644 index 0000000..f1c232f --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/OtherNamespace/GetEntityHandler.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Domain.OtherNamespace; +using MediatR; + +namespace Application.OtherNamespace +{ + internal sealed class GetEntityHandler : IRequestHandler + { + public Task Handle(GetEntityRequest request, CancellationToken cancellationToken) + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/OuterClassHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/OuterClassHandler.cs new file mode 100644 index 0000000..b5f0b71 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/OuterClassHandler.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.MediatR.Requests; +using MediatR; + +namespace DotNet6Core_Application.MediatR.Handlers; + +public class OutestClassHandler +{ + public class OuterClassHandler + { + public class InnerClassHandler : IRequestHandler + { + public Task Handle(InnerClassRequest request, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } + } + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/ReadonlyRecordStructHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/ReadonlyRecordStructHandler.cs new file mode 100644 index 0000000..59ef23a --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/ReadonlyRecordStructHandler.cs @@ -0,0 +1,15 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.MediatR.Requests; +using MediatR; + +namespace DotNet6Core_Application.MediatR.Handlers; + +public class ReadonlyRecordStructHandler : IRequestHandler +{ + public Task Handle(ReadonlyRecordStructRequest request, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/SecondCustomNotificationHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/SecondCustomNotificationHandler.cs new file mode 100644 index 0000000..c93749c --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/SecondCustomNotificationHandler.cs @@ -0,0 +1,15 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.MediatR.Notifications; +using MediatR; + +namespace DotNet6Core_Application.MediatR.Notifcations; + +internal sealed class SecondCustomNotificationHandler : INotificationHandler +{ + public Task Handle(CustomNotification notification, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/StartStreamingHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/StartStreamingHandler.cs new file mode 100644 index 0000000..ac027f1 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/StartStreamingHandler.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Domain; +using MediatR; + +namespace Application +{ + internal sealed class StartStreamingHandler : AsyncRequestHandler + { + protected override Task Handle(StartStreamingRequest request, CancellationToken cancellationToken) + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/TriggerDeletionHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/TriggerDeletionHandler.cs new file mode 100644 index 0000000..3980043 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/TriggerDeletionHandler.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Domain; +using MediatR; + +namespace Application +{ + internal sealed class TriggerDeletionHandler : IRequestHandler + { + public Task Handle(TriggerDeletionRequest request, CancellationToken cancellationToken) + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/XCommandHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/XCommandHandler.cs new file mode 100644 index 0000000..5ba0df2 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Handlers/XCommandHandler.cs @@ -0,0 +1,20 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.Entities; +using DotNetCore6_Domain.MediatR.Handlers; +using DotNetCore6_Domain.MediatR.Requests; + +namespace DotNet6Core_Application.MediatR.Handlers; + +public class XCommandHandler : ISharedCommandHandler +{ + public Task> Handle + ( + XCommandRequest request, + CancellationToken cancellationToken + ) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Notifications/CustomNotification.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Notifications/CustomNotification.cs new file mode 100644 index 0000000..6943320 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Notifications/CustomNotification.cs @@ -0,0 +1,9 @@ +using MediatR; + +namespace DotNetCore6_Domain.MediatR.Notifications; + +// FirstCustomNotificationHandler & SecondCustomNotificationHandler +public sealed class CustomNotification : INotification +{ + +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/CustomClassRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/CustomClassRequest.cs new file mode 100644 index 0000000..1f92e14 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/CustomClassRequest.cs @@ -0,0 +1,7 @@ +namespace DotNetCore6_Domain.MediatR.Requests; + +// CustomClassHandler & DuplicateHandler +public sealed class CustomClassRequest : ICustomRequest +{ + +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/CustomRecordRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/CustomRecordRequest.cs new file mode 100644 index 0000000..07b3df6 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/CustomRecordRequest.cs @@ -0,0 +1,7 @@ +namespace DotNetCore6_Domain.MediatR.Requests; + +// CustomRecordHandler +public record CustomRecordRequest : ICustomRequest +{ + +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/GetEntityRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/GetEntityRequest.cs new file mode 100644 index 0000000..002cb4a --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/GetEntityRequest.cs @@ -0,0 +1,9 @@ +using MediatR; + +namespace Domain +{ + public sealed class GetEntityRequest : IRequest + { + + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/ICustomRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/ICustomRequest.cs new file mode 100644 index 0000000..5bd736c --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/ICustomRequest.cs @@ -0,0 +1,8 @@ +using MediatR; + +namespace DotNetCore6_Domain.MediatR; + +public interface ICustomRequest : IRequest +{ + +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/InnerClassRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/InnerClassRequest.cs new file mode 100644 index 0000000..074977f --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/InnerClassRequest.cs @@ -0,0 +1,9 @@ +using MediatR; + +namespace DotNetCore6_Domain.MediatR.Requests; + +// InnerClassHandler +public sealed class InnerClassRequest : IRequest +{ + +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/NewRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/NewRequest.cs new file mode 100644 index 0000000..185df20 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/NewRequest.cs @@ -0,0 +1,9 @@ +using MediatR; + +namespace DotNetCore6_Domain.MediatR.Requests; + +// No handlers. +public class NewRequest : IRequest +{ + +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/CustomRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/CustomRequest.cs new file mode 100644 index 0000000..854ea13 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/CustomRequest.cs @@ -0,0 +1,7 @@ +namespace Domain.OtherNamespace +{ + public class CustomRequest : ICustomRequest + { + + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/GetEntityRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/GetEntityRequest.cs new file mode 100644 index 0000000..359e5cf --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/GetEntityRequest.cs @@ -0,0 +1,9 @@ +using MediatR; + +namespace Domain.OtherNamespace +{ + public sealed class GetEntityRequest : IRequest + { + + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/ICustomRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/ICustomRequest.cs new file mode 100644 index 0000000..27f0276 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherNamespace/ICustomRequest.cs @@ -0,0 +1,9 @@ +using MediatR; + +namespace Domain.OtherNamespace +{ + public interface ICustomRequest : IRequest + { + + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherRequest.cs new file mode 100644 index 0000000..0d4c471 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/OtherRequest.cs @@ -0,0 +1,7 @@ +namespace DotNetCore6_Domain.MediatR.Requests; + +// BaseRequestHandler +public sealed class OtherRequest : ICustomRequest +{ + +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/ReadonlyRecordStructRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/ReadonlyRecordStructRequest.cs new file mode 100644 index 0000000..de46fa9 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/ReadonlyRecordStructRequest.cs @@ -0,0 +1,6 @@ +using MediatR; + +namespace DotNetCore6_Domain.MediatR.Requests; + +// ReadonlyRecordStructHandler +public sealed record ReadonlyRecordStructRequest(string input) : IRequest; \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/StartStreamingRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/StartStreamingRequest.cs new file mode 100644 index 0000000..5e89828 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/StartStreamingRequest.cs @@ -0,0 +1,9 @@ +using MediatR; + +namespace Domain +{ + public sealed class StartStreamingRequest : IRequest + { + + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/TriggerDeletionRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/TriggerDeletionRequest.cs new file mode 100644 index 0000000..020407f --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/TriggerDeletionRequest.cs @@ -0,0 +1,9 @@ +using MediatR; + +namespace Domain +{ + public sealed class TriggerDeletionRequest : IRequest + { + + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/XCommandRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/XCommandRequest.cs new file mode 100644 index 0000000..641e712 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/MediatR/Requests/XCommandRequest.cs @@ -0,0 +1,10 @@ +using DotNetCore6_Domain.Entities; +using MediatR; + +namespace DotNetCore6_Domain.MediatR.Requests; + +// XCommandHandler +public class XCommandRequest : IRequest> {} + +public class XCommandResponse {} + diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/NewMediatorHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/NewMediatorHandler.cs new file mode 100644 index 0000000..f4a818b --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/NewMediatorHandler.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.Mediator; +using DotNetCore6_Domain.Mediator.Requests; +using Mediator; + +namespace DotNet6Core_Application.Mediator.Handlers; + +public class NewMediatorHandler : IRequestHandler +{ + public ValueTask Handle(NewMediatorRequest request, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/NewMediatorNotificationHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/NewMediatorNotificationHandler.cs new file mode 100644 index 0000000..74ddc9a --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/NewMediatorNotificationHandler.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.Mediator; +using DotNetCore6_Domain.Mediator.Notifications; +using Mediator; + +namespace DotNet6Core_Application.Mediator.Notifications; + +public class NewMediatorNotificationHandler : INotificationHandler +{ + public ValueTask Handle(NewMediatorNotification notification, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/OtherMediatorNotificationHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/OtherMediatorNotificationHandler.cs new file mode 100644 index 0000000..2ec38b9 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Handlers/OtherMediatorNotificationHandler.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using DotNetCore6_Domain.Mediator; +using DotNetCore6_Domain.Mediator.Notifications; +using Mediator; + +namespace DotNet6Core_Application.Mediator.Notifications; + +public class MediatorNotificationHandler : INotificationHandler +{ + public ValueTask Handle(NewMediatorNotification notification, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Notifications/NewMediatorNotification.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Notifications/NewMediatorNotification.cs new file mode 100644 index 0000000..cbfad84 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Notifications/NewMediatorNotification.cs @@ -0,0 +1,10 @@ +using DotNetCore6_Domain.Entities; +using Mediator; + +namespace DotNetCore6_Domain.Mediator.Notifications; + +// NewMediatorNotificationHandler & MediatorNotificationHandler +public class NewMediatorNotification : INotification +{ + +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Requests/NewMediatorRequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Requests/NewMediatorRequest.cs new file mode 100644 index 0000000..fc3537a --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/test/data/TestSolution/Mediator/Requests/NewMediatorRequest.cs @@ -0,0 +1,10 @@ +using DotNetCore6_Domain.Entities; +using Mediator; + +namespace DotNetCore6_Domain.Mediator.Requests; + +// NewMediatorHandler +public class NewMediatorRequest : IRequest>, IRequest +{ + +} \ No newline at end of file From 8f57e36b613c918ddb7c007fa126f7b20ed75d27 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Mon, 7 Sep 2026 09:44:50 -0400 Subject: [PATCH 11/18] test: extend MediatR request tests to cover newer versions - Updated `[TestPackages]` attribute in `MediatRRequestsTests` to include MediatR versions `13.1.0` and `14.2.0`. --- src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs index 53cbd50..aef2466 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs @@ -4,7 +4,7 @@ namespace Octelys.MediatorPlugin.Tests; [TestNetCoreLatest] -[TestPackages("MediatR/12.5.0")] +[TestPackages("MediatR/12.5.0", "MediatR/13.1.0", "MediatR/14.2.0")] [TestReferences("System.Runtime")] public class MediatRRequestsTests : LookupTestBase { From 15afe524497af14d0a5260dda09efad7559f8403 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Mon, 7 Sep 2026 09:50:50 -0400 Subject: [PATCH 12/18] Update. --- .../MediatRTestPackagesAttribute.cs | 11 + .../MediatorTestPackagesAttribute.cs | 11 + .../MediatR.Notifications.Tests.cs | 3 +- .../MediatR.Requests.Tests.cs | 3 +- .../Mediator.Notifications.Tests.cs | 3 +- .../Mediator.Requests.Tests.cs | 3 +- .../MediatorHandlerLookupTests.cs | 189 ------------------ src/dotnet/MediatorPlugin.Tests/Packages.cs | 16 ++ 8 files changed, 46 insertions(+), 193 deletions(-) create mode 100644 src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorTestPackagesAttribute.cs delete mode 100644 src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/Packages.cs diff --git a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs new file mode 100644 index 0000000..1204bf4 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs @@ -0,0 +1,11 @@ +using JetBrains.ReSharper.TestFramework; + +namespace Octelys.MediatorPlugin.Tests.Infrastructure; + +public sealed class MediatRTestPackagesAttribute : TestPackagesAttribute +{ + public MediatRTestPackagesAttribute() : base( + Tests.Packages.MediatR.V12, Tests.Packages.MediatR.V13, Tests.Packages.MediatR.V14) + { + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorTestPackagesAttribute.cs b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorTestPackagesAttribute.cs new file mode 100644 index 0000000..d825158 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorTestPackagesAttribute.cs @@ -0,0 +1,11 @@ +using JetBrains.ReSharper.TestFramework; + +namespace Octelys.MediatorPlugin.Tests.Infrastructure; + +public sealed class MediatorTestPackagesAttribute : TestPackagesAttribute +{ + public MediatorTestPackagesAttribute() : base( + Tests.Packages.Mediator.V3) + { + } +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs index 4bc9154..e5e8ba1 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs @@ -1,10 +1,11 @@ using JetBrains.ReSharper.TestFramework; using NUnit.Framework; +using Octelys.MediatorPlugin.Tests.Infrastructure; namespace Octelys.MediatorPlugin.Tests; [TestNetCoreLatest] -[TestPackages("MediatR/12.5.0")] +[MediatRTestPackages] [TestReferences("System.Runtime")] public class MediatRNotificationsTests : LookupTestBase { diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs index aef2466..d14fc9a 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs @@ -1,10 +1,11 @@ using JetBrains.ReSharper.TestFramework; using NUnit.Framework; +using Octelys.MediatorPlugin.Tests.Infrastructure; namespace Octelys.MediatorPlugin.Tests; [TestNetCoreLatest] -[TestPackages("MediatR/12.5.0", "MediatR/13.1.0", "MediatR/14.2.0")] +[MediatRTestPackages] [TestReferences("System.Runtime")] public class MediatRRequestsTests : LookupTestBase { diff --git a/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs index 0b59a64..23b088c 100644 --- a/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs @@ -1,10 +1,11 @@ using JetBrains.ReSharper.TestFramework; using NUnit.Framework; +using Octelys.MediatorPlugin.Tests.Infrastructure; namespace Octelys.MediatorPlugin.Tests; [TestNetCoreLatest] -[TestPackages("Mediator.Abstractions/3.0.1")] +[MediatorTestPackages] [TestReferences("System.Runtime")] public class MediatorNotificationsTests : LookupTestBase { diff --git a/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs index 24c8fed..7c15f0f 100644 --- a/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs @@ -1,10 +1,11 @@ using JetBrains.ReSharper.TestFramework; using NUnit.Framework; +using Octelys.MediatorPlugin.Tests.Infrastructure; namespace Octelys.MediatorPlugin.Tests; [TestNetCoreLatest] -[TestPackages("Mediator.Abstractions/3.0.1")] +[MediatorTestPackages] [TestReferences("System.Runtime")] public class MediatorRequestsTests : LookupTestBase { diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs b/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs deleted file mode 100644 index e3ca4dc..0000000 --- a/src/dotnet/MediatorPlugin.Tests/MediatorHandlerLookupTests.cs +++ /dev/null @@ -1,189 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using JetBrains.Lifetimes; -using JetBrains.ProjectModel; -using JetBrains.ReSharper.Psi; -using JetBrains.ReSharper.Psi.CSharp.Tree; -using JetBrains.ReSharper.Psi.Files; -using JetBrains.ReSharper.Psi.Tree; -using JetBrains.ReSharper.Resources.Shell; -using JetBrains.ReSharper.TestFramework; -using NUnit.Framework; -using ReSharper.MediatorPlugin.Services.Libraries; - -namespace Octelys.MediatorPlugin.Tests; - -/// -/// Exercises the handler lookup against a real solution: the framework restores MediatR, -/// builds the PSI caches, and the plugin resolves handlers the same way it does in the IDE. -/// -// BaseTestWithSolution defaults to [TestNetFramework35], whose platform package is not on -// nuget.org; the context action tests get their framework from CSharpContextActionExecuteTestBase. -[TestNetCoreLatest] -[TestPackages("MediatR/12.1.0")] -[TestReferences("System.Runtime")] -public class MediatorHandlerLookupTests : BaseTestWithSingleProject -{ - private string _requestTypeName; - private string[] _expectedHandlerNames; - - protected override string RelativeTestDataPath => nameof(MediatorHandlerLookupTests); - - /// - /// Runs inside the loaded test solution: the framework calls this once the project of the - /// current test has been restored and its PSI caches are ready. - /// - protected override void DoTest - ( - Lifetime lifetime, - ISolution solution - ) - { - solution.GetPsiServices().Files.CommitAllDocuments(); - - using (ReadLockCookie.Create()) - { - IIdentifier requestIdentifier = FindDeclarationIdentifier(solution, _requestTypeName); - - IEnumerable handlers = new LibraryAdaptor().FindHandlers(requestIdentifier); - - string[] handlerNames = handlers - .Select(handler => handler.ShortName) - .OrderBy(name => name) - .ToArray(); - - Assert.That(handlerNames, Is.EqualTo(_expectedHandlerNames.OrderBy(name => name).ToArray())); - } - } - - [Test] - public void FindHandlers_HandlerIsDeclaredInAnotherFile_HandlerReturned() - { - // Act & Assert. - AssertHandlersFor - ( - "SomeQuery", - ["SomeQueryHandler"], - "SomeQuery.cs", "SomeQueryHandler.cs" - ); - } - - [Test] - public void FindHandlers_RequestIsACommandWithoutResponse_HandlerReturned() - { - // Act & Assert. - AssertHandlersFor - ( - "SomeCommand", - ["SomeCommandHandler"], - "SomeCommand.cs" - ); - } - - [Test] - public void FindHandlers_RequestIsANotification_EveryHandlerReturned() - { - // Act & Assert. - AssertHandlersFor - ( - "SomethingHappened", - ["AuditSomethingHappenedHandler", "NotifySomethingHappenedHandler"], - "SomethingHappened.cs" - ); - } - - [Test] - public void FindHandlers_RequestHasNoHandler_NoHandlerReturned() - { - // Act & Assert. - AssertHandlersFor - ( - "OrphanQuery", - [], - "OrphanQuery.cs" - ); - } - - [Test] - public void FindHandlers_TypeIsNotARequest_NoHandlerReturned() - { - // Act & Assert. - AssertHandlersFor - ( - "NotARequest", - [], - "NotARequest.cs" - ); - } - - // Helper methods. - - /// - /// Loads the given files as a test solution and asserts that the request resolves to exactly - /// the expected handlers; the lookup itself runs in . - /// - private void AssertHandlersFor - ( - string requestTypeName, - string[] expectedHandlerNames, - params string[] fileNames - ) - { - _requestTypeName = requestTypeName; - _expectedHandlerNames = expectedHandlerNames; - - DoTestSolution(fileNames); - } - - /// - /// Returns the name token of the type declaration, which is the node the plugin receives - /// when the caret sits on a request in the editor. - /// - private static IIdentifier FindDeclarationIdentifier - ( - ISolution solution, - string typeName - ) - { - IIdentifier identifier = EnumerateIdentifiers(solution) - .FirstOrDefault - ( - candidate => candidate.Name == typeName && candidate.Parent is IClassLikeDeclaration - ); - - Assert.That(identifier, Is.Not.Null, $"No declaration of '{typeName}' was found in the test solution."); - - return identifier; - } - - private static IEnumerable EnumerateIdentifiers - ( - ISolution solution - ) - { - foreach (IProject project in solution.GetAllProjects()) - { - foreach (IProjectFile projectFile in project.GetAllProjectFiles(_ => true)) - { - IPsiSourceFile sourceFile = projectFile.ToSourceFile(); - - if (sourceFile is null) - { - continue; - } - - IFile psiFile = sourceFile.GetPrimaryPsiFile(); - - if (psiFile is null) - { - continue; - } - - foreach (IIdentifier identifier in psiFile.Descendants().ToEnumerable()) - { - yield return identifier; - } - } - } - } -} diff --git a/src/dotnet/MediatorPlugin.Tests/Packages.cs b/src/dotnet/MediatorPlugin.Tests/Packages.cs new file mode 100644 index 0000000..ebadf33 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Packages.cs @@ -0,0 +1,16 @@ +namespace Octelys.MediatorPlugin.Tests; + +public static class Packages +{ + public static class MediatR + { + public const string V12 = "MediatR/12.5.0"; + public const string V13 = "MediatR/13.1.0"; + public const string V14 = "MediatR/14.2.0"; + } + + public static class Mediator + { + public const string V3 = "Mediator.Abstractions/3.0.2"; + } +} \ No newline at end of file From 7c810e4f6d0438427a76cfbc6c318a57c76c5a69 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:12:24 -0400 Subject: [PATCH 13/18] test: centralize test solution file resolution and simplify test data 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. --- .../Infrastructure/TestSolutionFiles.cs | 53 +++++++++++++++++++ .../MediatorPlugin.Tests/LookupTestBase.cs | 38 ++++++++++--- ...ediatR.CreateHandlrContextAction.Tests.cs} | 3 +- .../MediatR.Notifications.Tests.cs | 2 +- .../MediatR.Requests.Tests.cs | 22 ++++---- .../Mediator.Notifications.Tests.cs | 2 +- .../Mediator.Requests.Tests.cs | 2 +- 7 files changed, 99 insertions(+), 23 deletions(-) create mode 100644 src/dotnet/MediatorPlugin.Tests/Infrastructure/TestSolutionFiles.cs rename src/dotnet/MediatorPlugin.Tests/{MediatrCreateHandlrContextActionTests.cs => MediatR.CreateHandlrContextAction.Tests.cs} (93%) diff --git a/src/dotnet/MediatorPlugin.Tests/Infrastructure/TestSolutionFiles.cs b/src/dotnet/MediatorPlugin.Tests/Infrastructure/TestSolutionFiles.cs new file mode 100644 index 0000000..7f328d6 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Infrastructure/TestSolutionFiles.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Octelys.MediatorPlugin.Tests.Infrastructure; + +/// +/// Enumerates every file under a library's folder in the shared TestSolution test data (plus the +/// common Entities folder), so lookup tests can load the whole library instead of curating a file +/// subset per test. +/// +public static class TestSolutionFiles +{ + private static readonly string TestSolutionPath = ResolveTestSolutionPath(); + + public static string[] MediatR { get; } = LibraryFiles("MediatR"); + + public static string[] Mediator { get; } = LibraryFiles("Mediator"); + + private static string[] LibraryFiles + ( + string libraryFolderName + ) + { + return new[] { libraryFolderName, "Entities" } + .SelectMany(EnumerateRelativeFiles) + .OrderBy(relativePath => relativePath) + .ToArray(); + } + + private static IEnumerable EnumerateRelativeFiles + ( + string folderName + ) + { + string folderPath = Path.Combine(TestSolutionPath, folderName); + + return Directory + .EnumerateFiles(folderPath, "*.cs", SearchOption.AllDirectories) + .Select(filePath => filePath.Substring(TestSolutionPath.Length + 1).Replace(Path.DirectorySeparatorChar, '/')); + } + + private static string ResolveTestSolutionPath + ( + [CallerFilePath] string sourceFilePath = "" + ) + { + string projectPath = Path.GetDirectoryName(Path.GetDirectoryName(sourceFilePath)); + + return Path.Combine(projectPath!, "test", "data", "TestSolution"); + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/LookupTestBase.cs b/src/dotnet/MediatorPlugin.Tests/LookupTestBase.cs index e522057..3bcc55e 100644 --- a/src/dotnet/MediatorPlugin.Tests/LookupTestBase.cs +++ b/src/dotnet/MediatorPlugin.Tests/LookupTestBase.cs @@ -72,7 +72,10 @@ params string[] fileNames /// /// Returns the name token of the type declaration, which is the node the plugin receives - /// when the caret sits on a request in the editor. + /// when the caret sits on a request in the editor. may be a + /// short name ("GetEntityRequest") when it is unique in the loaded files, or a fully + /// qualified name ("Domain.OtherNamespace.GetEntityRequest") to disambiguate types that + /// share a short name across namespaces. /// private static IIdentifier FindDeclarationIdentifier ( @@ -80,15 +83,34 @@ private static IIdentifier FindDeclarationIdentifier string typeName ) { - IIdentifier identifier = EnumerateIdentifiers(solution) - .FirstOrDefault - ( - candidate => candidate.Name == typeName && candidate.Parent is IClassLikeDeclaration - ); + bool isQualified = typeName.Contains('.'); + + IIdentifier[] candidates = EnumerateIdentifiers(solution) + .Where(candidate => candidate.Parent is IClassLikeDeclaration) + .Where(candidate => isQualified ? GetFullName(candidate) == typeName : candidate.Name == typeName) + .ToArray(); + + Assert.That + ( + candidates, + Has.Length.EqualTo(1), + candidates.Length == 0 + ? $"No declaration of '{typeName}' was found in the test solution." + : $"Multiple declarations of '{typeName}' were found: {string.Join(", ", candidates.Select(GetFullName))}. " + + "Qualify the name with its namespace to disambiguate." + ); + + return candidates[0]; + } - Assert.That(identifier, Is.Not.Null, $"No declaration of '{typeName}' was found in the test solution."); + private static string GetFullName + ( + IIdentifier identifier + ) + { + IClassLikeDeclaration declaration = (IClassLikeDeclaration)identifier.Parent; - return identifier; + return ((ITypeElement)declaration.DeclaredElement).GetClrName().FullName; } private static IEnumerable EnumerateIdentifiers diff --git a/src/dotnet/MediatorPlugin.Tests/MediatrCreateHandlrContextActionTests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlrContextAction.Tests.cs similarity index 93% rename from src/dotnet/MediatorPlugin.Tests/MediatrCreateHandlrContextActionTests.cs rename to src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlrContextAction.Tests.cs index 62036b8..9e9981e 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatrCreateHandlrContextActionTests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlrContextAction.Tests.cs @@ -1,11 +1,12 @@ using JetBrains.ReSharper.FeaturesTestFramework.Intentions; using JetBrains.ReSharper.TestFramework; using NUnit.Framework; +using Octelys.MediatorPlugin.Tests.Infrastructure; using ReSharper.MediatorPlugin.Actions; namespace Octelys.MediatorPlugin.Tests; -[TestPackages("MediatR/12.1.0")] +[MediatRTestPackages] [TestReferences("System.Runtime")] // needed for IReadOnlyCollection type public class MediatrCreateHandlrContextActionTests : CSharpContextActionExecuteTestBase { diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs index e5e8ba1..62b8f43 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs @@ -17,7 +17,7 @@ public void FindHandlers_NotificationHasMultipleHandlers_EveryHandlerReturned() ( "CustomNotification", ["FirstCustomNotificationHandler", "SecondCustomNotificationHandler"], - "MediatR/Notifications/CustomNotification.cs", "MediatR/Handlers/FirstCustomNotificationHandler.cs", "MediatR/Handlers/SecondCustomNotificationHandler.cs" + TestSolutionFiles.MediatR ); } } diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs index d14fc9a..a9d96b1 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs @@ -15,9 +15,9 @@ public void FindHandlers_HandlerDeclaredInSameNamespace_HandlerReturned() // Act & Assert. AssertHandlersFor ( - "GetEntityRequest", + "Domain.GetEntityRequest", ["GetEntityHandler"], - "MediatR/Requests/GetEntityRequest.cs", "MediatR/Handlers/GetEntityHandler.cs", "Entities/GetEntityResponse.cs" + TestSolutionFiles.MediatR ); } @@ -27,9 +27,9 @@ public void FindHandlers_RequestAndHandlerAreInACustomNamespace_HandlerReturned( // Act & Assert. AssertHandlersFor ( - "GetEntityRequest", + "Domain.OtherNamespace.GetEntityRequest", ["GetEntityHandler"], - "MediatR/Requests/OtherNamespace/GetEntityRequest.cs", "MediatR/Handlers/OtherNamespace/GetEntityHandler.cs", "Entities/OtherNamespace/GetEntityResponse.cs" + TestSolutionFiles.MediatR ); } @@ -41,7 +41,7 @@ public void FindHandlers_RequestImplementsCustomBaseRequestInterface_EveryHandle ( "CustomClassRequest", ["CustomClassHandler", "DuplicateHandler"], - "MediatR/Requests/ICustomRequest.cs", "MediatR/Requests/CustomClassRequest.cs", "MediatR/Handlers/CustomClassHandler.cs", "MediatR/Handlers/DuplicateHandler.cs" + TestSolutionFiles.MediatR ); } @@ -53,7 +53,7 @@ public void FindHandlers_RequestIsARecord_HandlerReturned() ( "CustomRecordRequest", ["CustomRecordHandler"], - "MediatR/Requests/ICustomRequest.cs", "MediatR/Requests/CustomRecordRequest.cs", "MediatR/Handlers/CustomRecordHandler.cs" + TestSolutionFiles.MediatR ); } @@ -65,7 +65,7 @@ public void FindHandlers_HandlerIsNestedInsideOuterClasses_HandlerReturned() ( "InnerClassRequest", ["InnerClassHandler"], - "MediatR/Requests/InnerClassRequest.cs", "MediatR/Handlers/OuterClassHandler.cs" + TestSolutionFiles.MediatR ); } @@ -77,7 +77,7 @@ public void FindHandlers_HandlerInheritsFromAbstractBaseClass_HandlerReturned() ( "OtherRequest", ["BaseRequestHandler"], - "MediatR/Requests/ICustomRequest.cs", "MediatR/Requests/OtherRequest.cs", "MediatR/Requests/NewRequest.cs", "MediatR/Handlers/BaseRequestHandler.cs" + TestSolutionFiles.MediatR ); } @@ -89,7 +89,7 @@ public void FindHandlers_RequestHasNoHandler_NoHandlerReturned() ( "NewRequest", [], - "MediatR/Requests/NewRequest.cs" + TestSolutionFiles.MediatR ); } @@ -101,7 +101,7 @@ public void FindHandlers_RequestIsAReadonlyRecord_HandlerReturned() ( "ReadonlyRecordStructRequest", ["ReadonlyRecordStructHandler"], - "MediatR/Requests/ReadonlyRecordStructRequest.cs", "MediatR/Handlers/ReadonlyRecordStructHandler.cs", "Entities/ReadonlyRecordStructResponse.cs" + TestSolutionFiles.MediatR ); } @@ -113,7 +113,7 @@ public void FindHandlers_HandlerImplementsSharedGenericHandlerInterface_HandlerR ( "XCommandRequest", ["XCommandHandler"], - "MediatR/Requests/XCommandRequest.cs", "MediatR/Handlers/XCommandHandler.cs", "MediatR/Handlers/ISharedCommandHandler.cs", "Entities/Dto.cs" + TestSolutionFiles.MediatR ); } } \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs index 23b088c..c2253ab 100644 --- a/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs @@ -17,7 +17,7 @@ public void FindHandlers_NotificationHasMultipleHandlers_EveryHandlerReturned() ( "NewMediatorNotification", ["NewMediatorNotificationHandler", "MediatorNotificationHandler"], - "Mediator/Notifications/NewMediatorNotification.cs", "Mediator/Handlers/NewMediatorNotificationHandler.cs", "Mediator/Handlers/OtherMediatorNotificationHandler.cs", "Entities/Dto.cs" + TestSolutionFiles.Mediator ); } } diff --git a/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs index 7c15f0f..3a0b1d8 100644 --- a/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs @@ -17,7 +17,7 @@ public void FindHandlers_RequestImplementsMultipleRequestInterfaces_HandlerRetur ( "NewMediatorRequest", ["NewMediatorHandler"], - "Mediator/Requests/NewMediatorRequest.cs", "Mediator/Handlers/NewMediatorHandler.cs", "Entities/Dto.cs" + TestSolutionFiles.Mediator ); } } From 8c439b0fff94753c0d43bcf92656dd05c1967dc5 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:28:33 -0400 Subject: [PATCH 14/18] test: refine MediatR test attribute and class naming - Updated `[MediatRTestPackages]` attribute to exclude older MediatR versions (V12, V13). - Fixed class name typo from `MediatrCreateHandlrContextActionTests` to `MediatRCreateHandlrContextActionTests` for consistency. --- .../Infrastructure/MediatRTestPackagesAttribute.cs | 2 +- .../MediatR.CreateHandlrContextAction.Tests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs index 1204bf4..36b596d 100644 --- a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs +++ b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs @@ -5,7 +5,7 @@ namespace Octelys.MediatorPlugin.Tests.Infrastructure; public sealed class MediatRTestPackagesAttribute : TestPackagesAttribute { public MediatRTestPackagesAttribute() : base( - Tests.Packages.MediatR.V12, Tests.Packages.MediatR.V13, Tests.Packages.MediatR.V14) + Tests.Packages.MediatR.V14) { } } \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlrContextAction.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlrContextAction.Tests.cs index 9e9981e..d381c79 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlrContextAction.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlrContextAction.Tests.cs @@ -8,9 +8,9 @@ namespace Octelys.MediatorPlugin.Tests; [MediatRTestPackages] [TestReferences("System.Runtime")] // needed for IReadOnlyCollection type -public class MediatrCreateHandlrContextActionTests : CSharpContextActionExecuteTestBase +public class MediatRCreateHandlrContextActionTests : CSharpContextActionExecuteTestBase { - protected override string RelativeTestDataPath => nameof(MediatrCreateHandlrContextActionTests); + protected override string RelativeTestDataPath => nameof(MediatRCreateHandlrContextActionTests); protected override string ExtraPath => ""; From 06606c41fbbf82cf54a7a8315ee33012e98cf756 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:44:47 -0400 Subject: [PATCH 15/18] test: split MediatR tests by version and refactor base classes - 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 --- .../MediatRTestPackagesAttribute.cs | 11 -------- .../MediatRV12TestPackagesAttribute.cs | 10 +++++++ .../MediatRV13TestPackagesAttribute.cs | 10 +++++++ .../MediatRV14TestPackagesAttribute.cs | 10 +++++++ ...Tests.cs => MediatR.CreateHandlR.Tests.cs} | 8 +++--- .../MediatR.CreateHandlR.V12.Tests.cs | 8 ++++++ .../MediatR.CreateHandlR.V13.Tests.cs | 8 ++++++ .../MediatR.CreateHandlR.V14.Tests.cs | 8 ++++++ .../MediatR.Notifications.Tests.cs | 5 ++-- .../MediatR.Notifications.V12.Tests.cs | 8 ++++++ .../MediatR.Notifications.V13.Tests.cs | 8 ++++++ .../MediatR.Notifications.V14.Tests.cs | 8 ++++++ .../MediatR.Requests.Tests.cs | 3 +-- .../MediatR.Requests.V12.Tests.cs | 8 ++++++ .../MediatR.Requests.V13.Tests.cs | 8 ++++++ .../MediatR.Requests.V14.Tests.cs | 8 ++++++ .../MediatorPlugin.Tests.csproj | 27 +++++++++++++++++++ 17 files changed, 135 insertions(+), 21 deletions(-) delete mode 100644 src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV12TestPackagesAttribute.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV13TestPackagesAttribute.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV14TestPackagesAttribute.cs rename src/dotnet/MediatorPlugin.Tests/{MediatR.CreateHandlrContextAction.Tests.cs => MediatR.CreateHandlR.Tests.cs} (72%) create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V12.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V13.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V14.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V12.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V13.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V14.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V12.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V13.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V14.Tests.cs diff --git a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs deleted file mode 100644 index 36b596d..0000000 --- a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRTestPackagesAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JetBrains.ReSharper.TestFramework; - -namespace Octelys.MediatorPlugin.Tests.Infrastructure; - -public sealed class MediatRTestPackagesAttribute : TestPackagesAttribute -{ - public MediatRTestPackagesAttribute() : base( - Tests.Packages.MediatR.V14) - { - } -} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV12TestPackagesAttribute.cs b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV12TestPackagesAttribute.cs new file mode 100644 index 0000000..72a4053 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV12TestPackagesAttribute.cs @@ -0,0 +1,10 @@ +using JetBrains.ReSharper.TestFramework; + +namespace Octelys.MediatorPlugin.Tests.Infrastructure; + +public sealed class MediatRV12TestPackagesAttribute : TestPackagesAttribute +{ + public MediatRV12TestPackagesAttribute() : base(Tests.Packages.MediatR.V12) + { + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV13TestPackagesAttribute.cs b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV13TestPackagesAttribute.cs new file mode 100644 index 0000000..570a5e5 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV13TestPackagesAttribute.cs @@ -0,0 +1,10 @@ +using JetBrains.ReSharper.TestFramework; + +namespace Octelys.MediatorPlugin.Tests.Infrastructure; + +public sealed class MediatRV13TestPackagesAttribute : TestPackagesAttribute +{ + public MediatRV13TestPackagesAttribute() : base(Tests.Packages.MediatR.V13) + { + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV14TestPackagesAttribute.cs b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV14TestPackagesAttribute.cs new file mode 100644 index 0000000..dbce55b --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatRV14TestPackagesAttribute.cs @@ -0,0 +1,10 @@ +using JetBrains.ReSharper.TestFramework; + +namespace Octelys.MediatorPlugin.Tests.Infrastructure; + +public sealed class MediatRV14TestPackagesAttribute : TestPackagesAttribute +{ + public MediatRV14TestPackagesAttribute() : base(Tests.Packages.MediatR.V14) + { + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlrContextAction.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.Tests.cs similarity index 72% rename from src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlrContextAction.Tests.cs rename to src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.Tests.cs index d381c79..79882f8 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlrContextAction.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.Tests.cs @@ -1,19 +1,17 @@ using JetBrains.ReSharper.FeaturesTestFramework.Intentions; using JetBrains.ReSharper.TestFramework; using NUnit.Framework; -using Octelys.MediatorPlugin.Tests.Infrastructure; using ReSharper.MediatorPlugin.Actions; namespace Octelys.MediatorPlugin.Tests; -[MediatRTestPackages] [TestReferences("System.Runtime")] // needed for IReadOnlyCollection type -public class MediatRCreateHandlrContextActionTests : CSharpContextActionExecuteTestBase +public abstract class MediatRCreateHandlrContextActionTestsBase : CSharpContextActionExecuteTestBase { - protected override string RelativeTestDataPath => nameof(MediatRCreateHandlrContextActionTests); + protected override string RelativeTestDataPath => "MediatrCreateHandlrContextActionTests"; protected override string ExtraPath => ""; - + [Test, Order(0)] public void TestEnvironmentSetupCorrectly() => Assert.Pass(); [Test] public void TestCommand() => DoNamedTest(); [Test] public void TestSimpleQuery() => DoNamedTest(); diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V12.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V12.Tests.cs new file mode 100644 index 0000000..64d473b --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V12.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatRV12TestPackages] +public sealed class MediatRCreateHandlrContextActionTestsV12 : MediatRCreateHandlrContextActionTestsBase +{ +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V13.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V13.Tests.cs new file mode 100644 index 0000000..5285d93 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V13.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatRV13TestPackages] +public sealed class MediatRCreateHandlrContextActionTestsV13 : MediatRCreateHandlrContextActionTestsBase +{ +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V14.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V14.Tests.cs new file mode 100644 index 0000000..c927113 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.V14.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatRV14TestPackages] +public sealed class MediatRCreateHandlrContextActionTestsV14 : MediatRCreateHandlrContextActionTestsBase +{ +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs index 62b8f43..e8488ee 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs @@ -5,9 +5,8 @@ namespace Octelys.MediatorPlugin.Tests; [TestNetCoreLatest] -[MediatRTestPackages] [TestReferences("System.Runtime")] -public class MediatRNotificationsTests : LookupTestBase +public abstract class MediatRNotificationsTestsBase : LookupTestBase { [Test] public void FindHandlers_NotificationHasMultipleHandlers_EveryHandlerReturned() @@ -20,4 +19,4 @@ public void FindHandlers_NotificationHasMultipleHandlers_EveryHandlerReturned() TestSolutionFiles.MediatR ); } -} +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V12.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V12.Tests.cs new file mode 100644 index 0000000..9c52792 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V12.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatRV12TestPackages] +public sealed class MediatRNotificationsTestsV12 : MediatRNotificationsTestsBase +{ +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V13.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V13.Tests.cs new file mode 100644 index 0000000..f922f39 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V13.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatRV13TestPackages] +public sealed class MediatRNotificationsTestsV13 : MediatRNotificationsTestsBase +{ +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V14.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V14.Tests.cs new file mode 100644 index 0000000..6c84542 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.V14.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatRV14TestPackages] +public sealed class MediatRNotificationsTestsV14 : MediatRNotificationsTestsBase +{ +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs index a9d96b1..5232371 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs @@ -5,9 +5,8 @@ namespace Octelys.MediatorPlugin.Tests; [TestNetCoreLatest] -[MediatRTestPackages] [TestReferences("System.Runtime")] -public class MediatRRequestsTests : LookupTestBase +public abstract class MediatRRequestsTestsBase : LookupTestBase { [Test] public void FindHandlers_HandlerDeclaredInSameNamespace_HandlerReturned() diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V12.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V12.Tests.cs new file mode 100644 index 0000000..6fd53cb --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V12.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatRV12TestPackages] +public sealed class MediatRRequestsTestsV12 : MediatRRequestsTestsBase +{ +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V13.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V13.Tests.cs new file mode 100644 index 0000000..2724ed3 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V13.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatRV13TestPackages] +public sealed class MediatRRequestsTestsV13 : MediatRRequestsTestsBase +{ +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V14.Tests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V14.Tests.cs new file mode 100644 index 0000000..cf3bc55 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.V14.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatRV14TestPackages] +public sealed class MediatRRequestsTestsV14 : MediatRRequestsTestsBase +{ +} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj index 07ec743..5d557c9 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj +++ b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj @@ -19,6 +19,33 @@ + + MediatR.Notifications.Tests.cs + + + MediatR.Notifications.Tests.cs + + + MediatR.Notifications.Tests.cs + + + MediatR.Requests.Tests.cs + + + MediatR.Requests.Tests.cs + + + MediatR.Requests.Tests.cs + + + MediatR.CreateHandlR.Tests.cs + + + MediatR.CreateHandlR.Tests.cs + + + MediatR.CreateHandlR.Tests.cs + From db38f20a1fcc989387e3bb5d9bd4bf553aebd184 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:48:21 -0400 Subject: [PATCH 16/18] test: split Mediator tests by version and refactor base classes - 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. --- .../Infrastructure/MediatorTestPackagesAttribute.cs | 11 ----------- .../Infrastructure/MediatorV3TestPackagesAttribute.cs | 10 ++++++++++ .../Mediator.Notifications.Tests.cs | 3 +-- .../Mediator.Notifications.V3.Tests.cs | 8 ++++++++ .../MediatorPlugin.Tests/Mediator.Requests.Tests.cs | 3 +-- .../Mediator.Requests.V3.Tests.cs | 8 ++++++++ .../MediatorPlugin.Tests/MediatorPlugin.Tests.csproj | 6 ++++++ 7 files changed, 34 insertions(+), 15 deletions(-) delete mode 100644 src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorTestPackagesAttribute.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorV3TestPackagesAttribute.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.V3.Tests.cs create mode 100644 src/dotnet/MediatorPlugin.Tests/Mediator.Requests.V3.Tests.cs diff --git a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorTestPackagesAttribute.cs b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorTestPackagesAttribute.cs deleted file mode 100644 index d825158..0000000 --- a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorTestPackagesAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JetBrains.ReSharper.TestFramework; - -namespace Octelys.MediatorPlugin.Tests.Infrastructure; - -public sealed class MediatorTestPackagesAttribute : TestPackagesAttribute -{ - public MediatorTestPackagesAttribute() : base( - Tests.Packages.Mediator.V3) - { - } -} \ No newline at end of file diff --git a/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorV3TestPackagesAttribute.cs b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorV3TestPackagesAttribute.cs new file mode 100644 index 0000000..e337793 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Infrastructure/MediatorV3TestPackagesAttribute.cs @@ -0,0 +1,10 @@ +using JetBrains.ReSharper.TestFramework; + +namespace Octelys.MediatorPlugin.Tests.Infrastructure; + +public sealed class MediatorV3TestPackagesAttribute : TestPackagesAttribute +{ + public MediatorV3TestPackagesAttribute() : base(Tests.Packages.Mediator.V3) + { + } +} diff --git a/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs index c2253ab..427b33a 100644 --- a/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs @@ -5,9 +5,8 @@ namespace Octelys.MediatorPlugin.Tests; [TestNetCoreLatest] -[MediatorTestPackages] [TestReferences("System.Runtime")] -public class MediatorNotificationsTests : LookupTestBase +public abstract class MediatorNotificationsTestsBase : LookupTestBase { [Test] public void FindHandlers_NotificationHasMultipleHandlers_EveryHandlerReturned() diff --git a/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.V3.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.V3.Tests.cs new file mode 100644 index 0000000..dfec6d5 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.V3.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatorV3TestPackages] +public sealed class MediatorNotificationsTestsV3 : MediatorNotificationsTestsBase +{ +} diff --git a/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs index 3a0b1d8..dc2c573 100644 --- a/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs @@ -5,9 +5,8 @@ namespace Octelys.MediatorPlugin.Tests; [TestNetCoreLatest] -[MediatorTestPackages] [TestReferences("System.Runtime")] -public class MediatorRequestsTests : LookupTestBase +public abstract class MediatorRequestsTestsBase : LookupTestBase { [Test] public void FindHandlers_RequestImplementsMultipleRequestInterfaces_HandlerReturned() diff --git a/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.V3.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.V3.Tests.cs new file mode 100644 index 0000000..efd6ba9 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.V3.Tests.cs @@ -0,0 +1,8 @@ +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[MediatorV3TestPackages] +public sealed class MediatorRequestsTestsV3 : MediatorRequestsTestsBase +{ +} diff --git a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj index 5d557c9..f502f60 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj +++ b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj @@ -46,6 +46,12 @@ MediatR.CreateHandlR.Tests.cs + + Mediator.Notifications.Tests.cs + + + Mediator.Requests.Tests.cs + From 4b371cd9da577614629280584082f4ab3816aaa7 Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:56:46 -0400 Subject: [PATCH 17/18] test: remove unused MediatorHandlerLookup test data files - 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. --- .../MediatorHandlerLookupTests/NotARequest.cs | 5 ---- .../MediatorHandlerLookupTests/OrphanQuery.cs | 11 -------- .../MediatorHandlerLookupTests/SomeCommand.cs | 17 ------------- .../MediatorHandlerLookupTests/SomeQuery.cs | 11 -------- .../SomeQueryHandler.cs | 13 ---------- .../SomethingHappened.cs | 25 ------------------- 6 files changed, 82 deletions(-) delete mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/NotARequest.cs delete mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/OrphanQuery.cs delete mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeCommand.cs delete mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQuery.cs delete mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQueryHandler.cs delete mode 100644 src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomethingHappened.cs diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/NotARequest.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/NotARequest.cs deleted file mode 100644 index bbe3582..0000000 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/NotARequest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace ClassLibrary1; - -public class NotARequest -{ -} diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/OrphanQuery.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/OrphanQuery.cs deleted file mode 100644 index 1b68451..0000000 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/OrphanQuery.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MediatR; - -namespace ClassLibrary1; - -public class OrphanDto -{ -} - -public class OrphanQuery : IRequest -{ -} diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeCommand.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeCommand.cs deleted file mode 100644 index ac40b30..0000000 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeCommand.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using MediatR; - -namespace ClassLibrary1; - -public class SomeCommand : IRequest -{ -} - -public class SomeCommandHandler : IRequestHandler -{ - public Task Handle(SomeCommand request, CancellationToken cancellationToken) - { - return Task.CompletedTask; - } -} diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQuery.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQuery.cs deleted file mode 100644 index 2321a47..0000000 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQuery.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MediatR; - -namespace ClassLibrary1; - -public class SomeDto -{ -} - -public class SomeQuery : IRequest -{ -} diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQueryHandler.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQueryHandler.cs deleted file mode 100644 index c7846cc..0000000 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomeQueryHandler.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using MediatR; - -namespace ClassLibrary1; - -public class SomeQueryHandler : IRequestHandler -{ - public Task Handle(SomeQuery request, CancellationToken cancellationToken) - { - return Task.FromResult(new SomeDto()); - } -} diff --git a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomethingHappened.cs b/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomethingHappened.cs deleted file mode 100644 index f5b787a..0000000 --- a/src/dotnet/MediatorPlugin.Tests/test/data/MediatorHandlerLookupTests/SomethingHappened.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using MediatR; - -namespace ClassLibrary1; - -public class SomethingHappened : INotification -{ -} - -public class AuditSomethingHappenedHandler : INotificationHandler -{ - public Task Handle(SomethingHappened notification, CancellationToken cancellationToken) - { - return Task.CompletedTask; - } -} - -public class NotifySomethingHappenedHandler : INotificationHandler -{ - public Task Handle(SomethingHappened notification, CancellationToken cancellationToken) - { - return Task.CompletedTask; - } -} From 616dd91c1017779d5844c0291bbb44bb2d5085ce Mon Sep 17 00:00:00 2001 From: kzryzstof <38137839+kzryzstof@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:59:28 -0400 Subject: [PATCH 18/18] docs: remove "Conventions" section from AGENTS.md - --- AGENTS.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 06f4544..ebce905 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,13 +32,6 @@ dotnet test src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj `_PLACEHOLDER_` on purpose. CI stamps them via `update-version.sh`. Never commit a concrete version there. -## Conventions - -- Branches: `features/` or `bugs/`, PRs target `main`. -- Tests must follow [docs/unit-test-guidelines.md](docs/unit-test-guidelines.md): - `MethodName_ScenarioInPresentTense_ExpectedResult` naming, AAA section comments, and - one call per line in fluent chains. Read it before writing or editing a test class. - ## File editing - Modify files with your editor/patch tools (str-replace, create-file, apply-patch).