This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In your test… | |
@isTest | |
static void test_method_one() { | |
//If you're not using SmartFactory, you're doing it way too hard. (and wrong) | |
Account account = (Account)SmartFactory.createSObject('Account'); | |
insert account; | |
Test.startTest(); | |
MyFarawayClass.RunMockCalloutForTest(account.id); | |
Test.StopTest(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In a class far far away... | |
@future | |
global static void RunMockCalloutForTest(String accountId){ | |
TestRestClient trc = new TestRestClient(); | |
id aId; | |
try { | |
aId = (Id) accountId; | |
} catch (Exception e) { | |
throw new exception('Failed to cast given accountId into an actual id, Send me a valid id or else.'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF( | |
ISBLANK(Line_Item__c), | |
CASE( | |
TEXT(Platform_Line_Item__r.Fee_Structure__c), | |
"Media Spend", | |
IF( | |
End_date__c > TODAY(), | |
Monthly_Projected_Spend__c, | |
Monthly_Actual_Spend__c | |
), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Trigger DescriptiveTriggerNameHere on ObjectNameHere (execution,context,list){ | |
new YourTriggerLogicClassNameHere().run(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class AccountTriggerLogic Extends TriggerHandler{ | |
//... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class ContactTriggerLogic Extends TriggerHandler { | |
Map<Id,Account> newMap; | |
Public ContactTriggerLogic() { | |
this.newMap = (Map<Id, Account>) Trigger.newMap; | |
} | |
Public Contact addSnark(Contact c){ | |
if(!c.lastName.contains(' is awesome!')){ | |
c.lastName = c.lastName + ' is awesome!'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class ContactTriggerLogic Extends TriggerHandler { | |
Public ContactTriggerLogic() { | |
this.setMaxLoopCount(1); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override void afterUpdate() { | |
this.bypass('AccountTriggerHandler'); //yeah, if you could just ignore that accountTrigger, *that'd be great* | |
acc.Name = 'No Trigger'; // wait! where'd acc come from? … just keeping you on your toes. | |
update acc; // won't invoke the AccountTriggerHandler | |
this.clearBypass('AccountTriggerHandler'); // actually, yeah. need you run that accountTrigger. | |
acc.Name = 'With Trigger'; | |
update acc; // will invoke the AccountTriggerHandler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright (c) 2011, salesforce.com, inc. All rights reserved. | |
Redistribution and use of this software in source and binary forms, with or without modification, | |
are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright notice, this list of conditions | |
and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright notice, this list of | |
conditions and the following disclaimer in the documentation and/or other materials provided | |
with the distribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InitialViewController < UIViewController | |
def initWithNibName(nibNameOrNil, bundle:nibBundleOrNil) | |
super.initWithNibName(nibNameOrNil, bundle:nibBundleOrNil) | |
p "Inside InitialViewController" | |
if self | |
# Custom init code goes here | |
end | |
self | |
end |