Can somebody with experience explain how the registerNew() method in the fflib_SObjectUnitOfWork class works? I do not understand how you can have two methods with the same name and different params. On top of that, I do not understand where this class holds all the to be inserted records.
Link below for those of you that are not sure what I am talking about.
public void registerNew(SObject record)
{
registerNew(record, null, null);
}
/**
* Register a list of newly created SObject instances to be inserted when commitWork is called
*
* @param records A list of newly created SObject instances to be inserted during commitWork
**/
public void registerNew(List<SObject> records)
{
for (SObject record : records)
{
registerNew(record, null, null);
}
}
registerNew/Dirty(sobject)
rather thanregisterNew/Dirty(sobjectList)
makes it somewhat easier to use apexMocks to test expected "new/updated" record DML. See my blog post on this topic