You need to sign in to do that
Don't have an account?
test case help
this is my controller and test case i have marked the parts that are not covered in red please help cover them
controller
public class WoW_ManageListController
{
public List<FulfillWrapper> wrappers {get; set;}
public static Integer toDelIdent {get; set;}
public static Integer addCount {get; set;}
private Integer nextIdent=0;
public Invoice__c INC {get;set;}
public Decimal INVLICOUNT{get;set;}
public WoW_ManageListController ()
{
INC = [select id,Dev_Line_Item_Count__c from Invoice__c where id=:Apexpages.currentpage().getparameters().get('id')];
INVLICOUNT = INC.Dev_Line_Item_Count__c ;
system.debug('**********'+INC.id);
wrappers=new List<FulfillWrapper>();
for (Integer idx=0; idx<INVLICOUNT ; idx++)
{
wrappers.add(new FulfillWrapper(nextIdent++));
}
}
public void delWrapper()
{
Integer toDelPos=-1;
for (Integer idx=0; idx<wrappers.size(); idx++)
{
if (wrappers[idx].ident==toDelIdent)
{
toDelPos=idx;
}
}
if (-1!=toDelPos)
{
wrappers.remove(toDelPos);
}
}
public void addRows()
{
for (Integer idx=0; idx<addCount; idx++)
{
wrappers.add(new FulfillWrapper(nextIdent++));
}
}
public PageReference save()
{
List<Fulfillement__c> accs=new List<Fulfillement__c>();
for (FulfillWrapper wrap : wrappers)
{
accs.add(wrap.acc);
}
try
{
insert accs;
}
catch(dmlexception e)
{
// ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Oops An Error Occured!'));
return null;
}
// return new PageReference('/' + Schema.getGlobalDescribe().get('Invoice__c').getDescribe().getKeyPrefix() + '/o');
return new PageReference('/' + INC.id);
}
public class FulfillWrapper
{
public Fulfillement__c acc {get; private set;}
public Integer ident {get; private set;}
public list<Invoice_line_item__c> INVLI {get;set;}
public integer countinvli {get;set;}
public Invoice__c INC {get;set;}
public FulfillWrapper(Integer inIdent)
{
INC = [select id,Dev_Line_Item_Count__c from Invoice__c where id=:Apexpages.currentpage().getparameters().get('id')];
INVLI = [select id,item__c,Item__r.Type__c,quantity__c,Invoice_Number__c,Qty_fulfilled__c,warehouse__c from invoice_line_item__c where Invoice_Number__c=:INC.id AND Dev_Qty_to_be_Fulfilled__c >0 ];
countinvli = INVLI.size();
ident=inIdent;
acc=new Fulfillement__c(Item__c = INVLI[ident].item__c,Invoice_Line_Item__c=INVLI[ident].id,Invoice__c=INVLI[ident].Invoice_Number__c,qty_out__c = (INVLI[ident].Quantity__c-INVLI[ident].Qty_fulfilled__c),warehouse__c=INVLI[ident].warehouse__c,date__c=system.today());
}
}
}
test cAse
@isTest private class WoW_ManageListController_TC { static testMethod void ManageListController() { Invoice_Category__c ic=new Invoice_Category__c(); ic.name='sdsd'; ic.Active__c=true; insert ic; account a = new account(); a.name='sdds'; insert a; branch__c b = new branch__c(); b.name='sdsd'; b.Dev_Invoice_Auto_Number__c=67; insert b; Invoice__c in1=new Invoice__c(); in1.Invoice_Category__c=ic.id; //in.doctor__c= in1.Sales_Branch__c=b.id; in1.KPI_Branch__c=b.id; in1.name='sdfd'; in1.Patient__c=a.id; insert in1; Integer toDelIdent=0; ApexPages.currentPage().getParameters().put('id', in1.id); WoW_ManageListController cs = new WoW_ManageListController(); cs.delWrapper(); cs.addRows(); cs.save(); } }
No need to worry till the varibale is public......
ClassName.Variable = "Set some value which do not break the code . ";
Please mark it solved if this solves the issue . So other people would get benefit . :)
Thanks
SFDC_Evolve
All Answers
I know its not the best answer . .but its a one minute answer on seeing the code for coaverage .. :-
MAKE A OBJECT OF THE INNER CLASS :)
thanks thats a great help but how to cover the static variable
No need to worry till the varibale is public......
ClassName.Variable = "Set some value which do not break the code . ";
Please mark it solved if this solves the issue . So other people would get benefit . :)
Thanks
SFDC_Evolve