diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 2833606..623f85c 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -19,6 +19,51 @@ 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' + + # 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: | + $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" ` + --no-restore ` + --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' }} steps: diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..ebce905 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,41 @@ +# 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. + +## 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/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/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/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 new file mode 100644 index 0000000..3bcc55e --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/LookupTestBase.cs @@ -0,0 +1,146 @@ +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. 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 + ( + ISolution solution, + string typeName + ) + { + 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]; + } + + private static string GetFullName + ( + IIdentifier identifier + ) + { + IClassLikeDeclaration declaration = (IClassLikeDeclaration)identifier.Parent; + + return ((ITypeElement)declaration.DeclaredElement).GetClrName().FullName; + } + + 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/MediatrCreateHandlrContextActionTests.cs b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.Tests.cs similarity index 70% rename from src/dotnet/MediatorPlugin.Tests/MediatrCreateHandlrContextActionTests.cs rename to src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.Tests.cs index 947793d..79882f8 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatrCreateHandlrContextActionTests.cs +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.CreateHandlR.Tests.cs @@ -3,16 +3,15 @@ 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 -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 new file mode 100644 index 0000000..e8488ee --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Notifications.Tests.cs @@ -0,0 +1,22 @@ +using JetBrains.ReSharper.TestFramework; +using NUnit.Framework; +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[TestNetCoreLatest] +[TestReferences("System.Runtime")] +public abstract class MediatRNotificationsTestsBase : LookupTestBase +{ + [Test] + public void FindHandlers_NotificationHasMultipleHandlers_EveryHandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "CustomNotification", + ["FirstCustomNotificationHandler", "SecondCustomNotificationHandler"], + 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 new file mode 100644 index 0000000..5232371 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/MediatR.Requests.Tests.cs @@ -0,0 +1,118 @@ +using JetBrains.ReSharper.TestFramework; +using NUnit.Framework; +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[TestNetCoreLatest] +[TestReferences("System.Runtime")] +public abstract class MediatRRequestsTestsBase : LookupTestBase +{ + [Test] + public void FindHandlers_HandlerDeclaredInSameNamespace_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "Domain.GetEntityRequest", + ["GetEntityHandler"], + TestSolutionFiles.MediatR + ); + } + + [Test] + public void FindHandlers_RequestAndHandlerAreInACustomNamespace_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "Domain.OtherNamespace.GetEntityRequest", + ["GetEntityHandler"], + TestSolutionFiles.MediatR + ); + } + + [Test] + public void FindHandlers_RequestImplementsCustomBaseRequestInterface_EveryHandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "CustomClassRequest", + ["CustomClassHandler", "DuplicateHandler"], + TestSolutionFiles.MediatR + ); + } + + [Test] + public void FindHandlers_RequestIsARecord_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "CustomRecordRequest", + ["CustomRecordHandler"], + TestSolutionFiles.MediatR + ); + } + + [Test] + public void FindHandlers_HandlerIsNestedInsideOuterClasses_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "InnerClassRequest", + ["InnerClassHandler"], + TestSolutionFiles.MediatR + ); + } + + [Test] + public void FindHandlers_HandlerInheritsFromAbstractBaseClass_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "OtherRequest", + ["BaseRequestHandler"], + TestSolutionFiles.MediatR + ); + } + + [Test] + public void FindHandlers_RequestHasNoHandler_NoHandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "NewRequest", + [], + TestSolutionFiles.MediatR + ); + } + + [Test] + public void FindHandlers_RequestIsAReadonlyRecord_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "ReadonlyRecordStructRequest", + ["ReadonlyRecordStructHandler"], + TestSolutionFiles.MediatR + ); + } + + [Test] + public void FindHandlers_HandlerImplementsSharedGenericHandlerInterface_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "XCommandRequest", + ["XCommandHandler"], + TestSolutionFiles.MediatR + ); + } +} \ No newline at end of file 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/Mediator.Notifications.Tests.cs b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs new file mode 100644 index 0000000..427b33a --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Notifications.Tests.cs @@ -0,0 +1,22 @@ +using JetBrains.ReSharper.TestFramework; +using NUnit.Framework; +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[TestNetCoreLatest] +[TestReferences("System.Runtime")] +public abstract class MediatorNotificationsTestsBase : LookupTestBase +{ + [Test] + public void FindHandlers_NotificationHasMultipleHandlers_EveryHandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "NewMediatorNotification", + ["NewMediatorNotificationHandler", "MediatorNotificationHandler"], + TestSolutionFiles.Mediator + ); + } +} 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 new file mode 100644 index 0000000..dc2c573 --- /dev/null +++ b/src/dotnet/MediatorPlugin.Tests/Mediator.Requests.Tests.cs @@ -0,0 +1,22 @@ +using JetBrains.ReSharper.TestFramework; +using NUnit.Framework; +using Octelys.MediatorPlugin.Tests.Infrastructure; + +namespace Octelys.MediatorPlugin.Tests; + +[TestNetCoreLatest] +[TestReferences("System.Runtime")] +public abstract class MediatorRequestsTestsBase : LookupTestBase +{ + [Test] + public void FindHandlers_RequestImplementsMultipleRequestInterfaces_HandlerReturned() + { + // Act & Assert. + AssertHandlersFor + ( + "NewMediatorRequest", + ["NewMediatorHandler"], + TestSolutionFiles.Mediator + ); + } +} 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 87015bf..f502f60 100644 --- a/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj +++ b/src/dotnet/MediatorPlugin.Tests/MediatorPlugin.Tests.csproj @@ -4,20 +4,67 @@ net472 false latest - MediatorPlugin.Tests + Octelys.MediatorPlugin.Tests + Octelys.MediatorPlugin.Tests + + + + + 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 + + + Mediator.Notifications.Tests.cs + + + Mediator.Requests.Tests.cs + + + + + + + + + + + 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 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/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) { 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 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")]