Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:

env:
PROJECT_PATH: 'src/FreeMediator/FreeMediator.csproj'
SOLUTION_PATH: 'FreeMediator.sln'
SOLUTION_PATH: 'FreeMediator.slnx'
PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}/output
NUGET_SOURCE_URL: 'https://api.nuget.org/v3/index.json'

Expand All @@ -21,12 +21,12 @@ jobs:

steps:
- name: 'Checkout'
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: 'Install dotnet'
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x

- name: 'Restore packages'
run: dotnet restore ${{ env.SOLUTION_PATH }}
Expand All @@ -42,12 +42,12 @@ jobs:

steps:
- name: 'Checkout'
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: 'Install dotnet'
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x

- name: 'Restore packages'
run: dotnet restore ${{ env.SOLUTION_PATH }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
cancel-in-progress: true

env:
SOLUTION_PATH: 'FreeMediator.sln'
SOLUTION_PATH: 'FreeMediator.slnx'
PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}\output
NUGET_SOURCE_URL: 'https://api.nuget.org/v3/index.json'

Expand All @@ -22,12 +22,12 @@ jobs:

steps:
- name: 'Checkout'
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: 'Install dotnet'
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x

- name: 'Restore packages'
run: dotnet restore ${{ env.SOLUTION_PATH }}
Expand Down
13 changes: 13 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,18 @@
<PropertyGroup>
<Version>1.4.0</Version>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<Authors>Steffen Skov</Authors>
<Company>Steffen Skov</Company>
<Copyright>Steffen Skov 2025</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

</Project>

17 changes: 17 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project>
<PropertyGroup>
<!-- Enable central package management, https://learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management -->
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup Label="Main">
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.12"/>
</ItemGroup>
<ItemGroup Label="Tests">
<PackageVersion Include="NSubstitute" Version="6.2.0"/>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.10.1"/>
<PackageVersion Include="xunit.v3" Version="4.0.1"/>
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.11.2"/>
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.12"/>
</ItemGroup>
</Project>
43 changes: 0 additions & 43 deletions FreeMediator.sln

This file was deleted.

16 changes: 16 additions & 0 deletions FreeMediator.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Solution>
<Folder Name="/Solution Items/">
<File Path=".editorconfig" />
<File Path="CHANGELOG.md" />
<File Path="Directory.Build.props" />
<File Path="Directory.Packages.props" />
<File Path="README.md" />
</Folder>
<Folder Name="/src/">
<Project Path="src/FreeMediator/FreeMediator.csproj" />
</Folder>
<Folder Name="/tests/">
<Project Path="tests/FreeMediator.ManualHandlerRegistration/FreeMediator.ManualHandlerRegistration.csproj" />
<Project Path="tests/FreeMediator.UnitTests/FreeMediator.UnitTests.csproj" />
</Folder>
</Solution>
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
13 changes: 2 additions & 11 deletions src/FreeMediator/FreeMediator.csproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<Authors>Steffen Skov</Authors>
<Company>Steffen Skov</Company>
<Description>A FOSS re-imaging of the popular MediatR library, striving to stay syntax compatible with MediatR.</Description>
<Copyright>Steffen Skov 2025</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/steffenskov/FreeMediator</PackageProjectUrl>
<PackageTags>mediator, request, response, queries, commands, notifications, CQRS</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>

<ItemGroup>
<None Include="../../CHANGELOG.md" Pack="true" PackagePath="\"/>
<None Include="../../README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
rm TestResults -rf 2> /dev/null
rm coverage-report -rf 2> /dev/null

dotnet test --results-directory ./TestResults --collect:"XPlat Code Coverage"
dotnet test --results-directory ./TestResults --coverage --coverage-output-format cobertura

reportgenerator -reports:"TestResults/**/*.cobertura.xml" -targetdir:coverage-report -reporttypes:Html

reportgenerator -reports:"TestResults/*/coverage.cobertura.xml" -targetdir:coverage-report -reporttypes:Html
rm TestResults -rf 2> /dev/null

xdg-open coverage-report/index.htm
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\FreeMediator\FreeMediator.csproj"/>
</ItemGroup>
Expand Down
43 changes: 9 additions & 34 deletions tests/FreeMediator.UnitTests/FreeMediator.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,49 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<RootNamespace>FreeMediator.UnitTests</RootNamespace>
<TargetFramework>net9.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<!--
To enable the Microsoft Testing Platform 'dotnet test' experience, add property:
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>

To enable the Microsoft Testing Platform native command line experience, add property:
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>

For more information on Microsoft Testing Platform support in xUnit.net, please visit:
https://xunit.net/docs/getting-started/v3/microsoft-testing-platform
-->
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
</ItemGroup>


<ItemGroup>
<PackageReference Include="coverlet.collector" Version="10.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.12"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.12"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0"/>
<PackageReference Include="NSubstitute" Version="6.2.0"/>
<PackageReference Include="xunit" Version="2.9.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="4.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions"/>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="NSubstitute"/>
<PackageReference Include="xunit.v3"/>
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage"/>
</ItemGroup>


<ItemGroup>
<ProjectReference Include="..\..\src\FreeMediator\FreeMediator.csproj"/>
<ProjectReference Include="..\FreeMediator.ManualHandlerRegistration\FreeMediator.ManualHandlerRegistration.csproj"/>
Expand Down
12 changes: 6 additions & 6 deletions tests/FreeMediator.UnitTests/Pipeline/PipelineBehaviorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task Publish_WithTwoBehaviors_BehaviorsInvokedInCorrectOrder()
var notification = new NotificationWithBehavior("Hello world");

// Act
await _mediator.Publish(notification);
await _mediator.Publish(notification, TestContext.Current.CancellationToken);

// Assert
Assert.Equal(42, notification.FirstBehaviorProperty);
Expand All @@ -48,7 +48,7 @@ public async Task Publish_WithOpenBehavior_BehaviorInvoked()
var notification = new NotificationWithOpenBehavior("Hello world");

// Act
await _mediator.Publish(notification);
await _mediator.Publish(notification, TestContext.Current.CancellationToken);

// Assert
Assert.Equal(42, notification.BehaviorProperty);
Expand All @@ -61,7 +61,7 @@ public async Task Publish_WithPostProcessingBehavior_BehaviorInvokedAfterHandler
var notification = new NotificationWithPostProcessing { Message = "Hello world" };

// Act
await _mediator.Publish(notification);
await _mediator.Publish(notification, TestContext.Current.CancellationToken);

// Assert
Assert.Equal("Hello world", NotificationWithPostProcessingHandler.ReceivedMessage);
Expand All @@ -75,7 +75,7 @@ public async Task Send_WithTwoBehaviors_BehaviorsInvokedInCorrectOrder()
var request = new RequestWithBehavior("Hello world");

// Act
await _mediator.Send(request);
await _mediator.Send(request, TestContext.Current.CancellationToken);

// Assert
Assert.Equal(42, request.FirstBehaviorProperty);
Expand All @@ -89,7 +89,7 @@ public async Task Send_WithOpenBehavior_BehaviorInvoked()
var request = new RequestWithOpenBehavior("Hello world");

// Act
await _mediator.Send(request);
await _mediator.Send(request, TestContext.Current.CancellationToken);

// Assert
Assert.Equal(42, request.BehaviorProperty);
Expand All @@ -102,7 +102,7 @@ public async Task Send_WithPostProcessingBehavior_BehaviorInvokedAfterHandler()
var request = new RequestWithPostProcessing { Message = "Hello world" };

// Act
await _mediator.Send(request);
await _mediator.Send(request, TestContext.Current.CancellationToken);

// Assert
Assert.Equal("Hello world", RequestWithPostProcessingHandler.ReceivedMessage);
Expand Down
12 changes: 6 additions & 6 deletions tests/FreeMediator.UnitTests/Services/PublisherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task Publish_MultipleHandlers_AllAreInvoked()
var notification = new MultiRecipientNotification($"Hello world {Random.Shared.Next()}");

// Act
await _publisher.Publish(notification);
await _publisher.Publish(notification, TestContext.Current.CancellationToken);

// Assert
var firstHandledMessage = Assert.Single(FirstMultiRecipientHandler.HandledMessages);
Expand All @@ -46,7 +46,7 @@ public async Task Publish_NoHandlers_DoesNothing()
var notification = new NoRecipientNotification($"Hello world {Random.Shared.Next()}");

// Act
var ex = await Record.ExceptionAsync(async () => await _publisher.Publish(notification));
var ex = await Record.ExceptionAsync(async () => await _publisher.Publish(notification, TestContext.Current.CancellationToken));

// Assert
Assert.Null(ex);
Expand All @@ -59,7 +59,7 @@ public async Task Publish_MultipleHandlersOneThrows_ThrowsButInvokesAll()
var notification = new MultiRecipientWithExceptionNotification($"Hello world {Random.Shared.Next()}");

// Act && Assert
var ex = await Assert.ThrowsAsync<AggregateException>(async () => await _publisher.Publish(notification));
var ex = await Assert.ThrowsAsync<AggregateException>(async () => await _publisher.Publish(notification, TestContext.Current.CancellationToken));

var innerEx = Assert.Single(ex.InnerExceptions);
var handledMessage = Assert.Single(WorkingMultiRecipientHandler.HandledMessages);
Expand All @@ -82,8 +82,8 @@ public async Task Publish_GenericRequest_IsHandled()
var stringNotification = new GenericNotification<string>($"Hello world {Random.Shared.Next()}");

// Act
await _publisher.Publish(intNotification);
await _publisher.Publish(stringNotification);
await _publisher.Publish(intNotification, TestContext.Current.CancellationToken);
await _publisher.Publish(stringNotification, TestContext.Current.CancellationToken);

// Assert
var intMessage = Assert.Single(GenericNotificationHandler<GenericNotification<int>>.HandledMessages);
Expand All @@ -100,7 +100,7 @@ public async Task Publish_MultipleHandlersAllThrow_ThrowsAggregateException()
var notification = new ThrowingNotification($"Hello world {Random.Shared.Next()}");

// Act && Assert
var ex = await Assert.ThrowsAsync<AggregateException>(async () => await _publisher.Publish(notification));
var ex = await Assert.ThrowsAsync<AggregateException>(async () => await _publisher.Publish(notification, TestContext.Current.CancellationToken));

Assert.Contains(ex.InnerExceptions, e => e is InvalidOperationException { Message: "An error occurred while handling the notification." });
Assert.Contains(ex.InnerExceptions, e => e is NotSupportedException { Message: "An error occurred while handling the notification." });
Expand Down
Loading