forked from apex-enterprise-patterns/fflib-apex-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8849cc8
commit ac74a5f
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
...ework/default/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@isTest | ||
private without sharing class ortoo_DateLiteralsTest | ||
{ | ||
@isTest | ||
private static void today_whenReferenced_returnsTodaysDate() // NOPMD: Test method name format | ||
{ | ||
Date got = ortoo_DateLiterals.today; | ||
System.assertEquals( Date.today(), got, 'today, when referenced, is set to today' ); | ||
} | ||
|
||
@isTest | ||
private static void yesterday_whenReferenced_returnYesterdayBasedOnTheConfiguredToday() // NOPMD: Test method name format | ||
{ | ||
ortoo_DateLiterals.today = Date.newInstance( 2024, 03, 01 ); | ||
|
||
Test.startTest(); | ||
Date got = ortoo_DateLiterals.yesterday; | ||
Test.stopTest(); | ||
|
||
System.assertEquals( Date.newInstance( 2024, 02, 29 ), got, 'yesterday, when referenced, is set to yesterday, based on the configured "today"' ); | ||
} | ||
|
||
@isTest | ||
private static void tomorrow_whenReferenced_returnTomorrowBasedOnTheConfiguredToday() // NOPMD: Test method name format | ||
{ | ||
ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); | ||
|
||
Test.startTest(); | ||
Date got = ortoo_DateLiterals.tomorrow; | ||
Test.stopTest(); | ||
|
||
System.assertEquals( Date.newInstance( 2024, 03, 01 ), got, 'tomorrow, when referenced, is set to tomorrow, based on the configured "today"' ); | ||
} | ||
|
||
@isTest | ||
private static void startOfThisWeek_whenReferenced_returnsStartOfThisWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format | ||
{ | ||
ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); | ||
|
||
Test.startTest(); | ||
Date got = ortoo_DateLiterals.startOfThisWeek; | ||
Test.stopTest(); | ||
|
||
Date expectedEarliest = Date.newInstance( 2024, 02, 25 ); | ||
Date expectedLatest = Date.newInstance( 2024, 02, 26 ); | ||
|
||
ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfThisWeek, when referenced, is set to the start of this week, based on the configured "today" and the current user locale' ); | ||
} | ||
|
||
@isTest | ||
private static void endOfThisWeek_whenReferenced_returnsEndOfThisWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format | ||
{ | ||
ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 ); | ||
|
||
Test.startTest(); | ||
Date got = ortoo_DateLiterals.endOfThisWeek; | ||
Test.stopTest(); | ||
|
||
Date expectedEarliest = Date.newInstance( 2024, 03, 02 ); | ||
Date expectedLatest = Date.newInstance( 2024, 03, 03 ); | ||
|
||
ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfThisWeek, when referenced, is set to the stendart of this week, based on the configured "today" and the current user locale' ); | ||
} | ||
|
||
|
||
|
||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...ault/ortoo-core/default/classes/fflib-extension/tests/ortoo_DateLiteralsTest.cls-meta.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>52.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |