-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddPrimaryContactsTest.cls
37 lines (34 loc) · 1.14 KB
/
AddPrimaryContactsTest.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@isTest
private class AddPrimaryContactTest {
@testSetup
static void setup() {
List<Account> accounts = new List<Account>();
for (Integer i=0; i<50; i++) {
Account ny = new Account();
ny.Name = 'Test Account (NY)';
ny.BillingState = 'NY';
accounts.add(ny);
Account ca = new Account();
ca.Name = 'Test Account (CA)';
ca.BillingState = 'CA';
accounts.add(ca);
}
insert accounts;
}
static void myTest() {
Contact contactObj = new Contact(
FirstName = 'California',
LastName = 'Bob'
);
String state_abbrev = 'CA';
Test.startTest();
AddPrimaryContact apc = new AddPrimaryContact(contactObj, state_abbrev);
Id jobId = System.enqueueJob(apc);
Test.stopTest();
List<Account> accounts = [SELECT Id, (SELECT Contact.Name FROM Account.Contacts) FROM Account WHERE BillingState = 'CA'];
System.assertEquals(50, accounts.size());
for (Account a : accounts) {
System.assertEquals(a.Contacts.size(), 1);
}
}
}