daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @isTest
  2. private class CalculateShippingDateTest {
  3.    
  4. @testSetup static void setupData(){
  5.         Case caseOne = new Case(Status='New',
  6.                                 Origin='Web',
  7.                                 Subject='BusinessHoursTest');
  8.         List<Case> cases = new List<Case>();
  9.         cases.add(caseOne);
  10.         insert cases;
  11.     }
  12.  
  13.     @isTest static void addGMT(){
  14.         // retrieve our test case from the database
  15.         List<Case> cases = [SELECT Id, Subject, Shipping_Date__c
  16.                             FROM Case
  17.                             WHERE Subject='BusinessHoursTest' LIMIT 1];
  18.         // Call the addTwoBusinessDayToCase to calculate and populate the shipping date on our case
  19.         CalculateShippingDate.addTwoBusinessDaysToCase(cases);
  20.         // Calculate our expected Shipping Date for comparison
  21.         DateTime expectedShippingDate = BusinessDays.addGmt(System.today(), 2);
  22.         Date shipDate = expectedShippingDate.Date(); // we only care about the Date, not the Date + Time for our use case
  23.         Test.startTest();
  24.         // retrieve the updated record
  25.         Case fetchedCase = [SELECT ID, Shipping_Date__c
  26.                                    FROM Case
  27.                                    WHERE ID IN :cases];
  28.         // run the test - compare the expectedShippingDate to the actual Shipping_Date__c calculated on our cases
  29.         System.assertEquals(shipDate, fetchedCase.Shipping_Date__c, 'Expected 2-business days to be added.');
  30.         Test.stopTest();
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top