Created
April 21, 2014 21:00
-
-
Save afawcett/11156378 to your computer and use it in GitHub Desktop.
Attempt to create Standard Pricebook2 via JSON deserialize... fail sadly...
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
@IsTest | |
private with sharing class TestPricebook { | |
@IsTest private static void testPricebook() | |
{ | |
System.assertEquals(0, [select Id from Pricebook2 where IsStandard = true].size()); | |
Pricebook2 pb = (Pricebook2) JSON.deserialize('{"Name":"Standard", "IsStandard":"true"}', Pricebook2.class); | |
System.assertEquals(true, pb.IsStandard); | |
insert pb; | |
System.assertEquals(1, [select Id from Pricebook2 where IsStandard = true].size()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Haha, I was thinking about trying that out, just didn't get around to it. At least now I know, pity though, it would have been sweet to be able to write tests without SeeAllData on.
I've used JSON deserialize for writing to CreatedDate and and LastModifiedDate fields and it works a treat. I was wondering if it would work for formula fields too, have you tried this?