Skip to content

Commit 2ec3f65

Browse files
committed
wip: work on compilation errors
1 parent a1af999 commit 2ec3f65

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

Yubico.YubiKey/tests/unit/Yubico/YubiKey/Pipelines/CommandChainingTransformTests.cs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ public void Invoke_CommandApduWithoutData_InvokesNextTransformWithSameApdu()
7979
_ = transform.Invoke(commandApdu, typeof(object), typeof(object));
8080

8181
// Assert
82-
mockTransform.Verify(
83-
x =>
84-
x.Invoke(Arg.Is<CommandApdu>(a => a == commandApdu), Arg.Any<Type>(), Arg.Any<Type>()));
82+
mockTransform.Received(1).Invoke(
83+
Arg.Is<CommandApdu>(a => a == commandApdu),
84+
Arg.Any<Type>(),
85+
Arg.Any<Type>());
8586
}
8687

8788
[Fact]
@@ -115,9 +116,10 @@ public void Invoke_CommandApduWithSmallData_InvokesNextTransformWithSameApdu()
115116
_ = transform.Invoke(commandApdu, typeof(object), typeof(object));
116117

117118
// Assert
118-
mockTransform.Verify(
119-
x =>
120-
x.Invoke(Arg.Is<CommandApdu>(a => a == commandApdu), Arg.Any<Type>(), Arg.Any<Type>()));
119+
mockTransform.Received(1).Invoke(
120+
Arg.Is<CommandApdu>(a => a == commandApdu),
121+
Arg.Any<Type>(),
122+
Arg.Any<Type>());
121123
}
122124

123125
[Fact]
@@ -151,8 +153,11 @@ public void Invoke_CommandApduWithLargeDataBuffer_OrsHex10ToClaOnAllExceptLast()
151153

152154
_ = mockTransform.Invoke(Arg.Any<CommandApdu>(), Arg.Any<Type>(), Arg.Any<Type>())
153155
.Returns(new ResponseApdu(new byte[] { 0x90, 0x00 }))
154-
.Callback<CommandApdu, Type, Type>((a, b, c) => observedCla.Add(a.Cla));
155-
156+
.AndDoes(callInfo =>
157+
{
158+
var apdu = callInfo.ArgAt<CommandApdu>(0);
159+
observedCla.Add(apdu.Cla);
160+
});
156161
// Act
157162
_ = transform.Invoke(commandApdu, typeof(object), typeof(object));
158163

@@ -178,7 +183,11 @@ public void Invoke_CommandApduWithLargeDataBuffer_AllOtherApduPropertiesRemainUn
178183

179184
_ = mockTransform.Invoke(Arg.Any<CommandApdu>(), Arg.Any<Type>(), Arg.Any<Type>())
180185
.Returns(new ResponseApdu(new byte[] { 0x90, 0x00 }))
181-
.Callback<CommandApdu, Type, Type>((a, b, c) => observedApdus.Add(a));
186+
.AndDoes(callInfo =>
187+
{
188+
var apdu = callInfo.ArgAt<CommandApdu>(0);
189+
observedApdus.Add(apdu);
190+
});
182191

183192
// Act
184193
_ = transform.Invoke(commandApdu, typeof(object), typeof(object));
@@ -207,8 +216,11 @@ public void Invoke_CommandApduWithLargeDataBuffer_SplitsDataAcrossInvokeCalls()
207216

208217
_ = mockTransform.Invoke(Arg.Any<CommandApdu>(), Arg.Any<Type>(), Arg.Any<Type>())
209218
.Returns(new ResponseApdu(new byte[] { 0x90, 0x00 }))
210-
.Callback<CommandApdu, Type, Type>((a, b, c) => observedApdus.Add(a.Data.ToArray()));
211-
219+
.AndDoes(callInfo =>
220+
{
221+
var apdu = callInfo.ArgAt<CommandApdu>(0);
222+
observedApdus.Add(apdu.Data.ToArray());
223+
});
212224
// Act
213225
_ = transform.Invoke(commandApdu, typeof(object), typeof(object));
214226

@@ -217,7 +229,7 @@ public void Invoke_CommandApduWithLargeDataBuffer_SplitsDataAcrossInvokeCalls()
217229
Assert.Equal(new byte[] { 5, 6, 7, 8 }, observedApdus[1]);
218230
Assert.Equal(new byte[] { 9, 10 }, observedApdus[2]);
219231
}
220-
232+
221233
[Fact]
222234
public void Invoke_CommandApduWithLargeDataBuffer_DoesntProcessAllBytes()
223235
{
@@ -233,9 +245,10 @@ public void Invoke_CommandApduWithLargeDataBuffer_DoesntProcessAllBytes()
233245

234246
_ = mockTransform.Invoke(Arg.Any<CommandApdu>(), Arg.Any<Type>(), Arg.Any<Type>())
235247
.Returns(new ResponseApdu([], 0x6700))
236-
.Callback<CommandApdu, Type, Type>((a, b, c) =>
248+
.AndDoes(callInfo =>
237249
{
238-
observedApdus.Add(a.Data.ToArray());
250+
var apdu = callInfo.ArgAt<CommandApdu>(0);
251+
observedApdus.Add(apdu.Data.ToArray());
239252
});
240253

241254
// Act

0 commit comments

Comments
 (0)