@@ -49,7 +49,10 @@ public async Task Consume_ProduceAndConsumeProtocolFormat_ConsumedDataEqualsPubl
4949 await producer . PublishMessageAsync (
5050 MotorCloudEvent . CreateTestCloudEvent ( Encoding . UTF8 . GetBytes ( expectedMessage ) )
5151 ) ;
52- var received = await Task . WhenAny ( tcs . Task , executeTask , Task . Delay ( TimeSpan . FromSeconds ( 30 ) ) ) == tcs . Task ? await tcs . Task : null ;
52+ var received =
53+ await Task . WhenAny ( tcs . Task , executeTask , Task . Delay ( TimeSpan . FromSeconds ( 30 ) ) ) == tcs . Task
54+ ? await tcs . Task
55+ : null ;
5356 await cts . CancelAsync ( ) ;
5457 await executeTask ;
5558 await consumer . StopAsync ( ) ;
@@ -58,31 +61,18 @@ await producer.PublishMessageAsync(
5861 }
5962
6063 [ Fact ( Timeout = 50000 ) ]
61- public async Task Consume_ProduceAndConsumeJsonFormat_ConsumedDataEqualsPublished ( )
64+ public async Task Consume_ProduceAndConsumeJsonFormat_ThrowsUnhandledCloudEventFormatException ( )
6265 {
6366 const string expectedMessage = "hello-json" ;
6467 var queueName = _randomizerString . Generate ( ) ! ;
6568 await using var producer = GetProducer < string > ( queueName , CloudEventFormat . Json ) ;
66- await using var consumer = GetConsumer < string > ( queueName ) ;
6769 await producer . StartAsync ( ) ;
68- await consumer . StartAsync ( ) ;
69- var tcs = new TaskCompletionSource < byte [ ] > ( ) ;
70- consumer . ConsumeCallbackAsync = ( evt , _ ) =>
70+ await Assert . ThrowsAsync < UnhandledCloudEventFormatException > ( async ( ) =>
7171 {
72- tcs . TrySetResult ( evt . TypedData ) ;
73- return Task . FromResult ( ProcessedMessageStatus . Success ) ;
74- } ;
75- using var cts = new CancellationTokenSource ( ) ;
76- var executeTask = consumer . ExecuteAsync ( cts . Token ) ;
77- await producer . PublishMessageAsync (
78- MotorCloudEvent . CreateTestCloudEvent ( Encoding . UTF8 . GetBytes ( expectedMessage ) )
79- ) ;
80- var received = await Task . WhenAny ( tcs . Task , executeTask , Task . Delay ( TimeSpan . FromSeconds ( 30 ) ) ) == tcs . Task ? await tcs . Task : null ;
81- await cts . CancelAsync ( ) ;
82- await executeTask ;
83- await consumer . StopAsync ( ) ;
84- Assert . NotNull ( received ) ;
85- Assert . Equal ( expectedMessage , Encoding . UTF8 . GetString ( received ! ) ) ;
72+ await producer . PublishMessageAsync (
73+ MotorCloudEvent . CreateTestCloudEvent ( Encoding . UTF8 . GetBytes ( expectedMessage ) )
74+ ) ;
75+ } ) ;
8676 }
8777
8878 [ Fact ( Timeout = 50000 ) ]
@@ -269,7 +259,10 @@ public async Task Consume_SuccessfulMessage_ProtocolFormat_CloudEventAttributesR
269259 null
270260 ) ;
271261 await producer . PublishMessageAsync ( cloudEvent ) ;
272- var receivedEvent = await Task . WhenAny ( tcs . Task , executeTask , Task . Delay ( TimeSpan . FromSeconds ( 30 ) ) ) == tcs . Task ? await tcs . Task : null ;
262+ var receivedEvent =
263+ await Task . WhenAny ( tcs . Task , executeTask , Task . Delay ( TimeSpan . FromSeconds ( 30 ) ) ) == tcs . Task
264+ ? await tcs . Task
265+ : null ;
273266 await cts . CancelAsync ( ) ;
274267 await executeTask ;
275268 await consumer . StopAsync ( ) ;
0 commit comments