-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ApplicationMediatrSupportModuleTests
Signed-off-by: Serhii A. Hrytsenko <[email protected]>
- Loading branch information
1 parent
ea8bb84
commit d3981a1
Showing
5 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/HomeInventory/HomeInventory.Tests/Application/ApplicationMediatrSupportModuleTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using HomeInventory.Application.Framework; | ||
using HomeInventory.Modules.Interfaces; | ||
using HomeInventory.Tests.Modules; | ||
using MediatR; | ||
using MediatR.NotificationPublishers; | ||
|
||
namespace HomeInventory.Tests.Application; | ||
|
||
[SuppressMessage("ReSharper", "UnusedType.Global")] | ||
public sealed class ApplicationMediatrSupportModuleTests() : BaseModuleTest<ApplicationMediatrSupportModule>(static () => new()) | ||
{ | ||
private readonly SubjectBaseModuleWithMediatr _subject = new(); | ||
|
||
protected override IReadOnlyCollection<IModule> GetModules() => [_subject]; | ||
|
||
protected override void EnsureRegistered(IServiceCollection services) | ||
{ | ||
_subject.Configured.Should().BeTrue(); | ||
services.Should() | ||
.ContainSingleTransient<IMediator>() | ||
.And.ContainSingleTransient<ISender>() | ||
.And.ContainSingleTransient<IPublisher>() | ||
.And.ContainSingleTransient<INotificationPublisher>() | ||
.And.ContainSingleSingleton<MediatRServiceConfiguration>() | ||
.Which.ImplementationInstance.Should().BeOfType<MediatRServiceConfiguration>() | ||
.Which.NotificationPublisherType.Should().Be<TaskWhenAllPublisher>(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/HomeInventory/HomeInventory.Tests/Application/SubjectBaseModuleWithMediatr.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using HomeInventory.Application.Framework; | ||
|
||
namespace HomeInventory.Tests.Application; | ||
|
||
public sealed class SubjectBaseModuleWithMediatr : BaseModuleWithMediatr | ||
{ | ||
public bool Configured { get; private set; } | ||
|
||
public override void Configure(MediatRServiceConfiguration configuration) => Configured = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/HomeInventory/HomeInventory.Tests/Modules/DomainModuleTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters