28
28
* This test class demonstrates two approaches to unit testing, with and without DML, each has its own pros and cons
29
29
**/
30
30
@IsTest
31
- private class OpportunityTriggerHandlerTest
31
+ private class OpportunitiesTriggerHandlerTest
32
32
{
33
33
34
34
@IsTest
35
35
private static void testValidationWithoutDML ()
36
36
{
37
- OpportunityTriggerHandler opps = new OpportunityTriggerHandler (new Opportunity [] { new Opportunity ( Name = ' Test' , Type = ' Existing Account' ) } );
37
+ OpportunitiesTriggerHandler opps = new OpportunitiesTriggerHandler (new Opportunity [] { new Opportunity ( Name = ' Test' , Type = ' Existing Account' ) } );
38
38
opps .onValidate ();
39
39
System .assertEquals (1 , fflib_SObjectDomain .Errors .getAll ().size ());
40
40
System .assertEquals (' You must provide an Account for OpportunityTriggerHandler for existing Customers.' , fflib_SObjectDomain .Errors .getAll ()[0 ].message );
@@ -46,7 +46,7 @@ private class OpportunityTriggerHandlerTest
46
46
{
47
47
Opportunity opp = new Opportunity ( Name = ' Test' , Type = ' Existing Account' );
48
48
fflib_SObjectDomain .Test .Database .onInsert (new Opportunity [] { opp } );
49
- fflib_SObjectDomain .triggerHandler (OpportunityTriggerHandler .class );
49
+ fflib_SObjectDomain .triggerHandler (OpportunitiesTriggerHandler .class );
50
50
System .assertEquals (1 , fflib_SObjectDomain .Errors .getAll ().size ());
51
51
System .assertEquals (' You must provide an Account for OpportunityTriggerHandler for existing Customers.' , fflib_SObjectDomain .Errors .getAll ()[0 ].message );
52
52
System .assertEquals (Opportunity .AccountId , ((fflib_SObjectDomain .FieldError )fflib_SObjectDomain .Errors .getAll ()[0 ]).field );
@@ -58,7 +58,7 @@ private class OpportunityTriggerHandlerTest
58
58
Opportunity oldOpp = new Opportunity ( Name = ' Test' , Type = ' Existing Account' );
59
59
Opportunity newOpp = new Opportunity ( Name = ' Test' , Type = ' New Account' );
60
60
fflib_SObjectDomain .Test .Database .onUpdate (new Opportunity [] { newOpp }, new Map <Id , SObject > { newOpp .Id = > oldOpp } );
61
- fflib_SObjectDomain .triggerHandler (OpportunityTriggerHandler .class );
61
+ fflib_SObjectDomain .triggerHandler (OpportunitiesTriggerHandler .class );
62
62
System .assertEquals (1 , fflib_SObjectDomain .Errors .getAll ().size ());
63
63
System .assertEquals (' You cannot change the Opportunity type once it has been created.' , fflib_SObjectDomain .Errors .getAll ()[0 ].message );
64
64
System .assertEquals (Opportunity .Type , ((fflib_SObjectDomain .FieldError )fflib_SObjectDomain .Errors .getAll ()[0 ]).field );
@@ -69,7 +69,7 @@ private class OpportunityTriggerHandlerTest
69
69
{
70
70
Opportunity opp = new Opportunity ( Name = ' Test' );
71
71
fflib_SObjectDomain .Test .Database .onInsert (new Opportunity [] { opp } );
72
- fflib_SObjectDomain .triggerHandler (OpportunityTriggerHandler .class );
72
+ fflib_SObjectDomain .triggerHandler (OpportunitiesTriggerHandler .class );
73
73
System .assertEquals (fflib_SObjectDomain .Errors .getAll ().size (), 0 );
74
74
}
75
75
0 commit comments