Skip to content

Instantly share code, notes, and snippets.

@suddeb
Created April 25, 2015 15:56
Show Gist options
  • Save suddeb/5f4db9c4e8f72d6380b8 to your computer and use it in GitHub Desktop.
Save suddeb/5f4db9c4e8f72d6380b8 to your computer and use it in GitHub Desktop.
TestAccountHelper - Test Class for Future method
@isTest
public class TestAccountHelper {
public static Account clientAcc;
public static string salesforceLicenseId = [SELECT Id FROM profile WHERE Profile.UserLicense.Name='Salesforce' limit 1].id;
public static Market_Area__c Markt;
public static User salesforceLicUser;
private static void createUsers(){
salesforceLicUser = new User(
Alias = 'standt',
profileId = salesforceLicenseId ,
Email='standarduser@testorg.com',
EmailEncodingKey='UTF-8',
CommunityNickname = 'test13',
LastName='Testing',
LanguageLocaleKey='en_US',
LocaleSidKey='en_US',
TimeZoneSidKey='America/Los_Angeles',
UserName='test008@testorg.com'
);
insert salesforceLicUser;
}
private static void createAccount(){
Markt = new Market_Area__c(Market_Area_Code__c = 'ab120');
insert Markt;
createUsers();
clientAcc = new Account( Name = 'Test_1',
Site = '_www.test_1.se',
Type = 'Client',
BillingStreet = 'Gatan 1',
BillingCity = 'Stockholm',
BillingCountry = 'SWE',
BillingPostalCode = 'BS1 1AD',
recordTypeId=System.Label.Client_Contact_Record_Type,
Company_Role_Text__c='Client',
Market_Area__c = Markt.id,
Area_Manager__c = salesforceLicUser.id,
OwnerId = salesforceLicUser.id
);
insert clientAcc;
}
static testMethod void testUpdateAccountRecordForNotifyAdminWithFalse(){
TestAccountHelper.createAccount();
List<Id> allAccountIds = new List<Id>();
allAccountIds.add(clientAcc.Id);
Test.startTest();
AccountHelper.updateAccounts(false,allAccountIds);
Test.stopTest();
Account fetchedAccount = [SELECT ID,notifyAdmin__c FROM ACCOUNT WHERE ID =: clientAcc.ID];
System.assertEquals(false,fetchedAccount.notifyAdmin__c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment