File tree Expand file tree Collapse file tree 6 files changed +40
-1
lines changed
OpenMediator.Shared.Test/MediatorMiddlewares
OpenMediator.Unit.Test/Commands Expand file tree Collapse file tree 6 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1+ [ ![ codecov] ( https://codecov.io/gh/Sergi0Martin/OpenMediator/graph/badge.svg?token=MYOEKIL20M )] ( https://codecov.io/gh/Sergi0Martin/OpenMediator )
2+
13# OpenMediator
24Alternative for those who do not want to pay for a mediator implementation.
35
Original file line number Diff line number Diff line change 1111 <PackageTags >mediator;mediator-pattern</PackageTags >
1212 <Description >Alternative for those who do not want to pay for a mediator implementation.</Description >
1313 <Authors >Sergio Martin</Authors >
14- <Version >1.1.1 </Version >
14+ <Version >1.1.2 </Version >
1515 <RepositoryUrl >https://github.com/Sergi0Martin/OpenMediator</RepositoryUrl >
1616 <PackageProjectUrl >https://sergi0martin.github.io/OpenMediator</PackageProjectUrl >
1717 <PackageReadmeFile >README.md</PackageReadmeFile >
Original file line number Diff line number Diff line change 11using OpenMediator . Middlewares ;
2+ using System . Diagnostics . CodeAnalysis ;
23
34namespace OpenMediator . Shared . Test . MediatorMiddlewares ;
45
6+ [ ExcludeFromCodeCoverage ]
57public class CustomMediatorMiddleware ( TestDependency testDependency ) : IMediatorMiddleware
68{
79 public async Task ExecuteAsync < TCommand > ( TCommand command , Func < Task > next )
Original file line number Diff line number Diff line change 11using OpenMediator . Middlewares ;
2+ using System . Diagnostics . CodeAnalysis ;
23
34namespace OpenMediator . Shared . Test . MediatorMiddlewares ;
45
6+ [ ExcludeFromCodeCoverage ]
57public class SecondCustomMediatorMiddleware ( TestDependency testDependency ) : IMediatorMiddleware
68{
79 public async Task ExecuteAsync < TCommand > ( TCommand command , Func < Task > next )
Original file line number Diff line number Diff line change @@ -33,4 +33,21 @@ public async Task Send_Command_With_Response_Works()
3333 Assert . Equal ( result , expectedResult ) ;
3434 Assert . True ( _testDependency . Called ) ;
3535 }
36+
37+ [ Fact ]
38+ public async Task Send_Command_With_Response_Throw_If_Not_Registered ( )
39+ {
40+ // Arrange
41+ var command = new GetCarModelCommand ( 1 ) ;
42+
43+ // Act
44+ Func < Task > action = async ( ) => await _fixture . Mediator . SendAsync < GetCarModelCommand , string > ( command ) ;
45+
46+ // Assert
47+ var exception = await Assert . ThrowsAsync < InvalidOperationException > ( action ) ;
48+ Assert . Equal ( "Handler not found for command GetCarModelCommand" , exception . Message ) ;
49+ }
50+
51+ public record GetCarModelCommand ( int Id ) : ICommand < string > ;
52+
3653}
Original file line number Diff line number Diff line change @@ -28,4 +28,20 @@ public async Task Send_Command_Works()
2828 // Assert
2929 Assert . True ( _testDependency . Called ) ;
3030 }
31+
32+ [ Fact ]
33+ public async Task Send_Command_Throw_If_Not_Registered ( )
34+ {
35+ // Arrange
36+ var command = new CreateCarCommand ( 1 ) ;
37+
38+ // Act
39+ Func < Task > action = async ( ) => await _fixture . Mediator . SendAsync ( command ) ;
40+
41+ // Assert
42+ var exception = await Assert . ThrowsAsync < InvalidOperationException > ( action ) ;
43+ Assert . Equal ( "Handler not found for command CreateCarCommand" , exception . Message ) ;
44+ }
45+
46+ public record CreateCarCommand ( int Id ) : ICommand ;
3147}
You can’t perform that action at this time.
0 commit comments