No compulsory Fields in Attendance object,
public class showAttendance {
public List<WrapperAttendance> PastAttendance { get; set; }
public List<Attendance__c> PastList {get;set;}
public List<Employee__c> EmployeeList {get;set;}
public showAttendance()
{
PastAttendance= new List<WrapperAttendance>();
PastList = new List<Attendance__c>();
EmployeeList = [select id,Employee_Name__c from Employee__c where User__c =:UserInfo.getUserId()]; //to get the current user ---Login User
PastList = [select id ,Attendance_Date__c, Present__c from Attendance__c where Employee__c=:EmployeeList[0].id ORDER BY Attendance_Date__c desc];
for(Attendance__c tmp : PastList)
{
PastAttendance.add(new WrapperAttendance(tmp));
}
}
public class WrapperAttendance
{
public Attendance__c AWrapper {get;set;}
WrapperAttendance()
{
AWrapper = new Attendance__c();
}
WrapperAttendance(Attendance__c h)
{
AWrapper = h;
}
}
}
Test CLASS
@isTest
private class showAttendance_TestClass
{
static TestMethod void showAttendanceMethod()
{
public List<Attendance__c> PList;
Employee__c eobj=new Employee__c();
Attendance__c aobj =new Attendance__c();
eobj.Employee_Name__C = 'Nilesh';
eobj.Job_Role__c = 'JF-0014';
eobj.Email_ID__c='[email protected]';
eobj.Mobile_Number__c='9878787878';
insert eobj;
aobj.Attendance_Date__c = '4/17/2014';
aobj.Present__c='true';
aobj.Employee__c='Emp-0015';
insert aobj;
PList = new List<Attendnace__c>();
PList.add(aobj);
}
}