Skip to content

Instantly share code, notes, and snippets.

@olgaloza
Created April 12, 2018 05:40
Show Gist options
  • Save olgaloza/74bf59160c4ff287e57381b937ae4a6c to your computer and use it in GitHub Desktop.
Save olgaloza/74bf59160c4ff287e57381b937ae4a6c to your computer and use it in GitHub Desktop.
Homework 8 Trailhead - VerifyDate Unit Test
@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);
}
}
@BarshanCommits
Copy link

Please tell me where do I connect with you, so that I can be enlightened by you.
I am new to Salesforce, so would be very helpful if you can guide a little in terms of resources, concepts and practical implementation.

@olgaloza
Copy link
Author

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment