1-
2-
3- using System ;
1+ using System ;
42using System . Text . Json . Serialization ;
53using System . Threading ;
64using System . Threading . Tasks ;
@@ -25,10 +23,11 @@ public void BatchProcessorAttribute_WithMultipleHandlerTypes_ThrowsInvalidOperat
2523 } ;
2624
2725 // Act & Assert
28- var exception = Assert . Throws < InvalidOperationException > ( ( ) =>
26+ var exception = Assert . Throws < InvalidOperationException > ( ( ) =>
2927 attribute . CreateAspectHandler ( new object [ ] { new SQSEvent ( ) } ) ) ;
30-
31- Assert . Contains ( "Only one type of handler (traditional or typed) can be configured at a time" , exception . Message ) ;
28+
29+ Assert . Contains ( "Only one type of handler (traditional or typed) can be configured at a time" ,
30+ exception . Message ) ;
3231 }
3332
3433 [ Fact ]
@@ -38,10 +37,12 @@ public void BatchProcessorAttribute_WithNoHandlers_ThrowsInvalidOperationExcepti
3837 var attribute = new BatchProcessorAttribute ( ) ;
3938
4039 // Act & Assert
41- var exception = Assert . Throws < InvalidOperationException > ( ( ) =>
40+ var exception = Assert . Throws < InvalidOperationException > ( ( ) =>
4241 attribute . CreateAspectHandler ( new object [ ] { new SQSEvent ( ) } ) ) ;
43-
44- Assert . Contains ( "A record handler, record handler provider, typed record handler, or typed record handler provider is required" , exception . Message ) ;
42+
43+ Assert . Contains (
44+ "A record handler, record handler provider, typed record handler, or typed record handler provider is required" ,
45+ exception . Message ) ;
4546 }
4647
4748 [ Fact ]
@@ -55,9 +56,9 @@ public void BatchProcessorAttribute_WithInvalidJsonSerializerContext_ThrowsInval
5556 } ;
5657
5758 // Act & Assert
58- var exception = Assert . Throws < InvalidOperationException > ( ( ) =>
59+ var exception = Assert . Throws < InvalidOperationException > ( ( ) =>
5960 attribute . CreateAspectHandler ( new object [ ] { new SQSEvent ( ) } ) ) ;
60-
61+
6162 Assert . Contains ( "The provided JsonSerializerContext must inherit from" , exception . Message ) ;
6263 }
6364
@@ -116,6 +117,61 @@ public void BatchProcessorAttribute_BackwardCompatibility_WithTraditionalHandler
116117 Assert . NotNull ( handler ) ;
117118 }
118119
120+ [ Fact ]
121+ public void GetEventTypeFromArgs_WithNullArgs_ThrowsArgumentException ( )
122+ {
123+ // Arrange & Act
124+ var exception = Assert . Throws < System . Reflection . TargetInvocationException > ( ( ) =>
125+ typeof ( BatchProcessorAttribute )
126+ . GetMethod ( "GetEventTypeFromArgs" ,
127+ System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Static )
128+ . Invoke ( null , new object [ ] { null } ) ) ;
129+
130+ // AssertÏ
131+ Assert . IsType < ArgumentException > ( exception . InnerException ) ;
132+ Assert . Contains ( "The first function handler parameter must be of one of the following types" ,
133+ exception . InnerException . Message ) ;
134+ }
135+
136+ [ Fact ]
137+ public void GetEventTypeFromArgs_WithEmptyArgs_ThrowsArgumentException ( )
138+ {
139+ // Arrange
140+ var args = Array . Empty < object > ( ) ;
141+
142+ // Act
143+ var exception = Assert . Throws < System . Reflection . TargetInvocationException > ( ( ) =>
144+ typeof ( BatchProcessorAttribute )
145+ . GetMethod ( "GetEventTypeFromArgs" ,
146+ System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Static )
147+ . Invoke ( null , new object [ ] { args } ) ) ;
148+
149+ // Assert
150+ Assert . IsType < ArgumentException > ( exception . InnerException ) ;
151+ Assert . Contains ( "The first function handler parameter must be of one of the following types" ,
152+ exception . InnerException . Message ) ;
153+ }
154+
155+ [ Fact ]
156+ public void GetEventTypeFromArgs_WithInvalidEventType_ThrowsArgumentException ( )
157+ {
158+ // Arrange
159+ var args = new object [ ] { "invalid event type" } ;
160+
161+ // Act
162+ var exception = Assert . Throws < System . Reflection . TargetInvocationException > ( ( ) =>
163+ typeof ( BatchProcessorAttribute )
164+ . GetMethod ( "GetEventTypeFromArgs" ,
165+ System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Static )
166+ . Invoke ( null , new object [ ] { args } ) ) ;
167+
168+ // Assert
169+ Assert . IsType < ArgumentException > ( exception . InnerException ) ;
170+ Assert . Contains ( "The first function handler parameter must be of one of the following types" ,
171+ exception . InnerException . Message ) ;
172+ }
173+
174+
119175 // Test helper classes
120176 private class TestTypedRecordHandler : ITypedRecordHandler < TestData >
121177 {
@@ -135,7 +191,8 @@ public ITypedRecordHandler<TestData> Create()
135191
136192 private class TestTypedRecordHandlerWithContext : ITypedRecordHandlerWithContext < TestData >
137193 {
138- public Task < RecordHandlerResult > HandleAsync ( TestData data , ILambdaContext context , CancellationToken cancellationToken )
194+ public Task < RecordHandlerResult > HandleAsync ( TestData data , ILambdaContext context ,
195+ CancellationToken cancellationToken )
139196 {
140197 return Task . FromResult ( RecordHandlerResult . None ) ;
141198 }
@@ -157,4 +214,4 @@ private class TestData
157214
158215 // Removed TestJsonSerializerContext to avoid source generation conflicts
159216 }
160- }
217+ }
0 commit comments