+ Start a Discussion
baby prasanthi pattapubaby prasanthi pattapu 

Create a unit test for a simple Apex class, for this challenge when iam trying to create apex class VerifyData it is giving error not a legal name

Mahesh DMahesh D
Hi Prasanthi,

Please provide your existing class and test class so that we will help you.

Regards,
​Mahesh
Han Phyo AungHan Phyo Aung
Hi,
Use this code to win the challenge.

@isTest
public class TestVerifyDate {
    @isTest static void testCheckDate(){
        date d1=VerifyDate.CheckDates(system.today(),system.today().addDays(10));
        System.assertEquals(system.today().addDays(10),d1);
        
        date d2=VerifyDate.CheckDates(system.today(),system.today().addDays(78));
        System.assertEquals(system.today(),d2);
    }
}
Christophe_         LereverendChristophe_ Lereverend
Thanks @Han Phyo Aung

Works Perfectly! 

WaqarAhmedWaqarAhmed
@isTest
public with sharing class TestVerifyDate {
    
    @isTest public static void away30Days()
    {
        Date firsDate = Date.newInstance(21,03,26);
        Date secDate = Date.newInstance(21,05,21);
        Date expDate = Date.newInstance(20,03,31);

        Date foundDate = VerifyDate.CheckDates(firsDate,secDate);
        System.assertEquals(expDate,foundDate);
    }
    
    @isTest public static void withIn30Days()
    {
        Date firsDate = Date.newInstance(21,03,26);
        Date secDate = Date.newInstance(21,03,28);

        Date foundDate = VerifyDate.CheckDates(firsDate,secDate);
        System.assertEquals(secDate,foundDate);

    }
}


Hope  it will help 

Best of luck