I am writing a test class for a TriggerHandler called 'HasPotentialDuplicates'. I am checking to see if a duplicate record exists using a custom checkbox field I made called 'HasPotentialDuplicates'. The field updates to 'true' if there is a duplicate record.
I have a second method where I insert 2 accounts, with different names, then update them to the same name. This triggers the duplicate rule and should mark the 'HasPotentialDuplicates' checkbox as true.
My question is; When writing the SOQL, how can I differentiate between the records? They have the same names so I am unable to distinguish between them.
public static testMethod void test2() {
Account acc3 = new Account();
acc3.Name = 'Test3';
Account acc4 = new Account();
acc4.Name = 'Test4';
INSERT acc3;
INSERT acc4;
acc4.name = 'Test3';
UPDATE acc4;
Test.startTest();
Account HasPotentialDuplicate3 = [SELECT ID, Has_Potential_Duplicates__c FROM Account WHERE Name = 'Test3'];
Account HasPotentialDuplicate4 = [SELECT ID, Has_Potential_Duplicates__c FROM Account WHERE Name = 'Test3'];
Test.stopTest();
System.assertEquals(HasPotentialDuplicate3.Has_Potential_Duplicates__c, true);
System.assertEquals(HasPotentialDuplicate4.Has_Potential_Duplicates__c, true);
}