Skip to content

Commit

Permalink
Added direct test for the dynamic unit of work ordering resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Apr 22, 2022
1 parent be4e4c4 commit fdc89e8
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,35 @@ private without sharing class ortoo_DynamicSobjectUnitOfWorkTest
ortoo_Asserts.assertContains( 'SObject type Contact is invalid for publishing within this unit of work', exceptionMessage, 'registerPublishAfterFailureTransaction, when called with a non event, will throw an exception' );
}

@isTest
private static void onCommitWorkStarting_whenCalled_setsTheOrderOfTheOperations() // NOPMD: Test method name format
{
Opportunity opportunityRecord = new Opportunity( Name = 'test' );
Contact contactRecord = new Contact( LastName = 'test' );
Account accountRecord = new Account( Name = 'test' );

Test.startTest();

ortoo_DynamicSobjectUnitOfWork uow = new ortoo_DynamicSobjectUnitOfWork();

uow.registerNew( opportunityRecord );
uow.registerNew( contactRecord );
uow.registerNew( accountRecord );

uow.registerRelationship( contactRecord, Contact.AccountId, accountRecord );
uow.registerRelationship( opportunityRecord, Opportunity.AccountId, accountRecord );

uow.onCommitWorkStarting();

Test.stopTest();

List<SobjectType> expected = new List<SobjectType>{
Account.sobjectType, Contact.sobjectType, Opportunity.sobjectType
};

System.assertEquals( expected, uow.m_sObjectTypes, 'onCommitWorkStarting, when called, will set the order of operations' );
}

@isTest
private static void commitWork_whenGivenCircularReferences_throwsAnException() // NOPMD: Test method name format
{
Expand Down

0 comments on commit fdc89e8

Please sign in to comment.