You need to sign in to do that
Don't have an account?
neeedhelp
Test Code for Covering the Wrapper Class
My Apex Class is
Public class Myclass{ public class tempconwrapper{ public boolean selectedcheck; public void setselectedcheck(boolean b){this.selectedcheck = b;} public boolean getselectedcheck(){return selectedcheck;} public Temporary_Contact__c tempcon{get;set;} public tempconwrapper(temporary_contact__c temporary){ tempcon= temporary; selectedcheck=false; } } public list<tempconwrapper> gettemporarycontactlist(){ list<tempconwrapper> tempwrapperlist=new list<tempconwrapper>(); list<Temporary_contact__c> TemporaryList = [select id,Name,First_Name__c,Last_Name__c,Email__c,contact_list__c,Installment__c,Sno__c,Check_temp__c,Map_Contact__c,OrderNumber__c,Recurring__c,Xmldata__c,Master_Transaction_Number__c from Temporary_contact__c order by createddate desc ]; for(Temporary_Contact__c tempconlist: TemporaryList ){ tempwrapperlist.add(new tempconwrapper(tempconlist)); } return wrapperlist; } public pagereference processtempcon(){ set<Temporary_contact__c> tempconset = new set<Temporary_contact__c>(); for(tempconwrapper temp: gettemporarycontactlist()){ if(temp.selectedcheck == true) { //this Value is always false in the constructor //my code } } return null; } }
My Test Class for this is
myclass temporary = new myclass(); Temporary_Contact__c tc = new Temporary_Contact__c(OrderNumber__c='1321161610784412',First_Name__c='First',Last_Name__c='Last',Map_Contact__c=con.id,Installment__c=2,Check_Temp__c=true,Master_Transaction_Number__c='1210111712415518392'); insert tc; batchtemporarycls.tempconwrapper tempclass = new batchtemporarycls.tempconwrapper(tc); boolean b = tempclass.getselectedcheck(); tempclass.setselectedcheck(b); temporary.gettemporarycontactlist();
Tried different ways to cover the if(temp.selectedcheck == true) part but nothing helps.Any help would be greatly appreciated
Thanks
Hi,
I have updated the code. see below
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
All Answers
Hi,
You have to made some change in your controller. see below updated code. i have changed code in this method : gettemporarycontactlist()
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
Getting error as Constructor not defined: [batchtemporarycls.tempconwrapper].<Constructor>()
at
How Should I Overcome this problem.
Hi,
I have updated the code. see below
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator