File tree Expand file tree Collapse file tree
src/ServiceBus.AcceptanceTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ namespace ServiceBus . Tests
2+ {
3+ using System ;
4+ using NServiceBus . AcceptanceTesting ;
5+ using NServiceBus ;
6+ using NUnit . Framework ;
7+ using System . Threading . Tasks ;
8+
9+ public class When_receiving_with_sendonly
10+ {
11+ [ TestCase ( TransportTransactionMode . ReceiveOnly ) ]
12+ [ TestCase ( TransportTransactionMode . SendsAtomicWithReceive ) ]
13+ public void Should_invoke_the_handler_to_process_it ( TransportTransactionMode transactionMode )
14+ {
15+ var exception = Assert . ThrowsAsync < InvalidOperationException > ( ( ) => Scenario . Define < ScenarioContext > ( )
16+ . WithComponent ( new FunctionWithSendOnlyConfiguration ( transactionMode ) )
17+ . Done ( c => c . EndpointsStarted )
18+ . Run ( ) ) ;
19+
20+ StringAssert . Contains ( "This endpoint cannot process messages because it is configured in send-only mode." , exception . Message ) ;
21+ }
22+
23+
24+ class FunctionWithSendOnlyConfiguration : FunctionEndpointComponent
25+ {
26+ public FunctionWithSendOnlyConfiguration ( TransportTransactionMode transactionMode ) : base ( transactionMode )
27+ {
28+ CustomizeConfiguration = configuration => configuration . AdvancedConfiguration . SendOnly ( ) ;
29+
30+ Messages . Add ( new TestMessage ( ) ) ;
31+ }
32+
33+ public class TestMessageHandler : IHandleMessages < TestMessage >
34+ {
35+ public Task Handle ( TestMessage message , IMessageHandlerContext context ) => Task . CompletedTask ;
36+ }
37+ }
38+
39+ class TestMessage : IMessage
40+ {
41+ }
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments