1

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);

    }
}
6
  • Have you already tried something ? Commented Apr 18, 2014 at 5:53
  • Since i am new @ SFDC,I am trying with this,but I am not getting that how to deal with that Wrapper class- Commented Apr 18, 2014 at 6:24
  • @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; Commented Apr 18, 2014 at 6:27
  • 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); } } Commented Apr 18, 2014 at 6:27
  • 1
    Nilesh, as you can see, highfive has updated your question with the code you've posted in the comments. Updating your question with additional info or details is the recommended thing to do on stackexchange sites. In that way all info is clearly readable and not hidden away in a comment. Commented Apr 18, 2014 at 7:13

0

Browse other questions tagged .