Below is my controller and test class, i am getting an error while compiling test class, how can i use controller object in test class? Controller
public class ERFormController
{
public Event_Request__c t1{get;set;}
public String stateCode {get;set;}
public List<npe5__Affiliation__c > SchoolList{get;set;}
// public List<SelectOption> mySchools {get;set;}
public ERFormController(ApexPages.StandardController controller)
{
t1 = new Event_Request__c();
stateCode = '';
getdetail();
}
public PageReference save() {
if (validate()) {
String edit_start_time,edit_end_time;
String event_starttime = t1.Start_Time__c+':'+t1.Start_Time_mm__c+' '+t1.Start_Time_Meridian__c;
String event_endtime = t1.End_Time__c+':'+t1.End_Time_mm__c+' '+t1.End_Time_Meridian__c;
String stime = t1.Start_Date__c+' '+event_starttime;
String etime = t1.End_Date__c+' '+event_endtime;
t1.State__c = stateCode;
System.debug('Start Time in Date Time:'+t1.StartTime__c);
t1.StartTime__c = DateTime.parse(stime);
t1.EndTime__c = DateTime.parse(etime);
insert t1;
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Record Created Successfully.Thank you!'));
PageReference pg = new PageReference('/Event_list');
pg.setRedirect(true);
return pg;
} else {
return null;
}
}
public PageReference cancel()
{
PageReference pg = new PageReference('/Event_list');
return pg;
}
}
Test Class
@isTest(SeeAllData=true)
public class ERFormControllerTest{
@isTest static void testFormintsert(){
ApexPages.StandardController sc = new ApexPages.StandardController(Event_Request__c);
Event_Request__c t = new Event_Request__c();
ERFormController obj = new ERFormController(sc);
obj.t1=t;
t.EventName__c = 'Test';
t.EventType__c = 'On Site Training';
t.Start_date__c = '02/27/2016';
t.Start_Time__c = '3';
t.Start_Time_mm__c = '30';
t.Start_Time_meridian__c = 'PM';
t.End_date__c = '02/26/2016';
t.End_Time__c = '4';
t.End_Time_mm__c = '30';
t.End_Time_meridian__c = 'PM';
t.Timezone__c = 'pacific';
t.Description__c = 'Testing';
t.City__c = 'Chicago';
t.State__c = 'IL';
t.Zip__c = '60616';
t.Need_Volunteers__c = 'No';
obj.save();
}
}