@@ -153,6 +153,7 @@ public void Invoke_CommandApduWithLargeDataBuffer_OrsHex10ToClaOnAllExceptLast()
153
153
154
154
_ = mockTransform
155
155
. Setup ( x => x . Invoke ( It . IsAny < CommandApdu > ( ) , It . IsAny < Type > ( ) , It . IsAny < Type > ( ) ) )
156
+ . Returns ( new ResponseApdu ( [ ] , 0x90 ) )
156
157
. Callback < CommandApdu , Type , Type > ( ( a , b , c ) => observedCla . Add ( a . Cla ) ) ;
157
158
158
159
// Act
@@ -180,6 +181,7 @@ public void Invoke_CommandApduWithLargeDataBuffer_AllOtherApduPropertiesRemainUn
180
181
181
182
_ = mockTransform
182
183
. Setup ( x => x . Invoke ( It . IsAny < CommandApdu > ( ) , It . IsAny < Type > ( ) , It . IsAny < Type > ( ) ) )
184
+ . Returns ( new ResponseApdu ( [ ] , 0x90 ) )
183
185
. Callback < CommandApdu , Type , Type > ( ( a , b , c ) => observedApdus . Add ( a ) ) ;
184
186
185
187
// Act
@@ -209,6 +211,7 @@ public void Invoke_CommandApduWithLargeDataBuffer_SplitsDataAcrossInvokeCalls()
209
211
210
212
_ = mockTransform
211
213
. Setup ( x => x . Invoke ( It . IsAny < CommandApdu > ( ) , It . IsAny < Type > ( ) , It . IsAny < Type > ( ) ) )
214
+ . Returns ( new ResponseApdu ( [ ] , 0x90 ) )
212
215
. Callback < CommandApdu , Type , Type > ( ( a , b , c ) => observedApdus . Add ( a . Data . ToArray ( ) ) ) ;
213
216
214
217
// Act
@@ -219,5 +222,34 @@ public void Invoke_CommandApduWithLargeDataBuffer_SplitsDataAcrossInvokeCalls()
219
222
Assert . Equal ( new byte [ ] { 5 , 6 , 7 , 8 } , observedApdus [ 1 ] ) ;
220
223
Assert . Equal ( new byte [ ] { 9 , 10 } , observedApdus [ 2 ] ) ;
221
224
}
225
+
226
+ [ Fact ]
227
+ public void Invoke_CommandApduWithLargeDataBuffer_DoesntProcessAllBytes ( )
228
+ {
229
+ var observedApdus = new List < byte [ ] > ( ) ;
230
+
231
+ // Arrange
232
+ var mockTransform = new Mock < IApduTransform > ( ) ;
233
+ var transform = new CommandChainingTransform ( mockTransform . Object ) { MaxChunkSize = 4 } ;
234
+ var commandApdu = new CommandApdu
235
+ {
236
+ Data = new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 }
237
+ } ;
238
+
239
+ _ = mockTransform
240
+ . Setup ( x => x . Invoke ( It . IsAny < CommandApdu > ( ) , It . IsAny < Type > ( ) , It . IsAny < Type > ( ) ) )
241
+ . Returns ( new ResponseApdu ( [ ] , 0x6700 ) )
242
+ . Callback < CommandApdu , Type , Type > ( ( a , b , c ) =>
243
+ {
244
+ observedApdus . Add ( a . Data . ToArray ( ) ) ;
245
+ } ) ;
246
+
247
+ // Act
248
+ _ = transform . Invoke ( commandApdu , typeof ( object ) , typeof ( object ) ) ;
249
+
250
+ // Assert
251
+ // Should only make one pass with 4 bytes, before exiting
252
+ Assert . Equal ( 4 , observedApdus [ 0 ] . Length ) ;
253
+ }
222
254
}
223
255
}
0 commit comments