Created
April 12, 2018 05:40
-
-
Save olgaloza/74bf59160c4ff287e57381b937ae4a6c to your computer and use it in GitHub Desktop.
Homework 8 Trailhead - VerifyDate Unit Test
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 class TestVerifyDate { | |
//testing that if date2 is within 30 days of date1, should return date 2 | |
@isTest static void testDate2within30daysofDate1() { | |
Date date1 = date.newInstance(2018, 03, 20); | |
Date date2 = date.newInstance(2018, 04, 11); | |
Date resultDate = VerifyDate.CheckDates(date1,date2); | |
Date testDate = Date.newInstance(2018, 04, 11); | |
System.assertEquals(testDate,resultDate); | |
} | |
//testing that date2 is before date1. Should return "false" | |
@isTest static void testDate2beforeDate1() { | |
Date date1 = date.newInstance(2018, 03, 20); | |
Date date2 = date.newInstance(2018, 02, 11); | |
Date resultDate = VerifyDate.CheckDates(date1,date2); | |
Date testDate = Date.newInstance(2018, 02, 11); | |
System.assertNotEquals(testDate, resultDate); | |
} | |
//Test date2 is outside 30 days of date1. Should return end of month. | |
@isTest static void testDate2outside30daysofDate1() { | |
Date date1 = date.newInstance(2018, 03, 20); | |
Date date2 = date.newInstance(2018, 04, 25); | |
Date resultDate = VerifyDate.CheckDates(date1,date2); | |
Date testDate = Date.newInstance(2018, 03, 31); | |
System.assertEquals(testDate,resultDate); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@BarshanCommits, I'm afraid training will not be possible but there are a lot of resources on Trailhead. It's a great resource and you can study at your own pace. Best of luck!