assertPendingFields function
Asserts M7A fields on a MontyPending against fixture expectations.
Checks these fixture keys (all optional — missing keys are no-ops):
expectedFnName— expectedfunctionNameexpectedArgs— expectedarguments(JSON equality)expectedKwargs— expectedkwargs(null or map equality)expectedCallIdNonZero— assertscallId != 0expectedMethodCall— expectedmethodCallboolean
Implementation
void assertPendingFields(MontyPending pending, Map<String, dynamic> fixture) {
final expectedFnName = fixture['expectedFnName'] as String?;
if (expectedFnName != null) {
expect(
pending.functionName,
expectedFnName,
reason: 'Fixture #${fixture['id']}: expected functionName '
'"$expectedFnName", got: "${pending.functionName}"',
);
}
final expectedArgs = fixture['expectedArgs'] as List?;
if (expectedArgs != null) {
expect(
jsonEncode(pending.arguments),
jsonEncode(expectedArgs),
reason: 'Fixture #${fixture['id']}: expected args '
'${jsonEncode(expectedArgs)}, got: ${jsonEncode(pending.arguments)}',
);
}
final expectedKwargs = fixture['expectedKwargs'];
if (fixture.containsKey('expectedKwargs')) {
if (expectedKwargs == null) {
expect(
pending.kwargs,
isNull,
reason: 'Fixture #${fixture['id']}: expected null kwargs, '
'got: ${pending.kwargs}',
);
} else {
final expectedMap = Map<String, Object?>.from(
expectedKwargs as Map<String, dynamic>,
);
expect(
pending.kwargs,
expectedMap,
reason: 'Fixture #${fixture['id']}: expected kwargs '
'$expectedMap, got: ${pending.kwargs}',
);
}
}
if (fixture['expectedCallIdNonZero'] == true) {
expect(
pending.callId,
isNot(0),
reason: 'Fixture #${fixture['id']}: expected nonzero callId, '
'got: ${pending.callId}',
);
}
final expectedMethodCall = fixture['expectedMethodCall'] as bool?;
if (expectedMethodCall != null) {
expect(
pending.methodCall,
expectedMethodCall,
reason: 'Fixture #${fixture['id']}: expected methodCall '
'$expectedMethodCall, got: ${pending.methodCall}',
);
}
}