Issue description
When I need to verify fflib_ISObjectUnitOfWork.registerDirty(SObject, SObjectField, SObject) method call on a mocked instance, I'm getting this exception:
fflib_ApexMocks.ApexMocksException: The number of matchers defined (3). does not match the number expected (1)
To Reproduce
I've created classes to reproduce the issue.
Steps to reproduce the behavior:
Create a scratch org with fflib-apex-common deployed
Deploy following classes SimpleClass, SimpleClass_Test
Run the test method SimpleClass_Test.testIssue()
See error
SimpleClass.cls
public with sharing class SimpleClass {
public void modifyData(Account a, Contact c, fflib_ISObjectUnitOfWork uow) {
uow.registerDirty(c, Contact.AccountId, a);
}
}
SimpleClass_Test.cls
@IsTest
private class SimpleClass_Test {
@IsTest
private static void testIssue() {
fflib_ApexMocks mocks = new fflib_ApexMocks();
fflib_ISObjectUnitOfWork uowMock = new fflib_SObjectMocks.SObjectUnitOfWork(mocks);
Account a = new Account();
Contact c = new Contact();
SimpleClass sc = new SimpleClass();
Test.startTest();
sc.modifyData(a, c, uowMock);
Test.stopTest();
((fflib_ISObjectUnitOfWork) mocks.verify(uowMock, mocks.times(1)))
.registerDirty(
fflib_Match.sObjectOfType(Contact.SObjectType),
fflib_Match.anySObjectField(),
fflib_Match.sObjectOfType(Account.SObjectType)
);
}
}
Expected behavior
This test method is expected to execute without any issue and result in a test pass.
Error message observed
fflib_ApexMocks.ApexMocksException: The number of matchers defined (3). does not match the number expected (1)
If you are using matchers all arguments must be passed in as matchers.
For example myList.add(fflib_Match.anyInteger(), 'String') should be defined as myList.add(fflib_Match.anyInteger(), fflib_Match.eq('String')).
Class.fflib_Match: line 51, column 1
Class.fflib_AnyOrder.verify: line 23, column 1
Class.fflib_MethodVerifier.verifyMethodCall: line 20, column 1
Class.fflib_ApexMocks.verifyMethodCall: line 132, column 1
Class.fflib_ApexMocks: line 256, column 1
Class.fflib_ApexMocks: line 236, column 1
Class.fflib_SObjectMocks.SObjectUnitOfWork.registerDirty: line 145, column 1
Class.SimpleClass_Test.testIssue: line 20, column 1
Version
Reproducible for me on latest version of fflib-apex-common.
Issue description When I need to verify fflib_ISObjectUnitOfWork.registerDirty(SObject, SObjectField, SObject) method call on a mocked instance, I'm getting this exception: fflib_ApexMocks.ApexMocksException: The number of matchers defined (3). does not match the number expected (1)
To Reproduce I've created classes to reproduce the issue.
Steps to reproduce the behavior:
SimpleClass.cls
SimpleClass_Test.cls
Expected behavior This test method is expected to execute without any issue and result in a test pass.
Error message observed
Version Reproducible for me on latest version of fflib-apex-common.