Please help me to write test class for event object. I am getting only 25% code coverage.
// Method to validate start and End Time on events
public static void ValidateStartEndTime(List<Event> evts) {
for(Event ev: evts)
{
if(ev.StartDateTime.time() < Time.newInstance(7, 30, 0, 0))
{
ev.StartDateTime.addError('Start time should be greater than or equals to 7:30 AM');
}
if(ev.EndDateTime.time() > Time.newInstance(18, 00, 0, 0))
{
ev.EndDateTime.addError('End time should be less than or equals to 6 PM');
}
}
}
Test class:
@isTest
public class EventTrigger_Test {
static testMethod void myUnitTest1(){
Event e = new Event();
e.StartDateTime=system.today();
e.EndDateTime=system.today()+5;
Test.startTest();
insert e;
Test.stopTest();
}
}