You need to sign in to do that
Don't have an account?
saurabh sharma
no code coverage
My apex class is
public class AlternateNamecl {
public Id URLId = System.currentPagereference().getParameters().get('id');
sobjecttype gettingWhatIDType ;
public string sUrl {get;set;}
public AlternateNamecl(ApexPages.StandardController controller) {
if(URLId != null){
gettingWhatIDType = URLId.getSObjectType();
String sEncodeID = EncodingUtil.base64Encode(blob.valueof(URLId+'-713ABP-XSH48-37VPK3J'));
if(gettingWhatIDType == PreEmploy_Case__c.sObjectType){
sUrl = Salesforcecl.GetSidesDotNetUrl() + 'AlternateName.aspx?ci='+sEncodeID ;
}
else{
sUrl = Salesforcecl.GetSidesDotNetUrl() + 'AlternateName.aspx?oi='+sEncodeID ;
}
}
}
}
And my test class is
@isTest
public class AlternateNamecl_Test{
static void testPageMethods() {
Alternate_Names__c an = new Alternate_Names__c();
insert an;
PageReference pRef = Page.CaseAlternateName;
pRef.getParameters().put('id', an.Id);
Test.setCurrentPage(pRef);
Test.startTest();
ApexPages.StandardController controller = new ApexPages.StandardController(an);
AlternateNamecl oAdd = new AlternateNamecl(controller);
Test.stopTest();
}
}
public class AlternateNamecl {
public Id URLId = System.currentPagereference().getParameters().get('id');
sobjecttype gettingWhatIDType ;
public string sUrl {get;set;}
public AlternateNamecl(ApexPages.StandardController controller) {
if(URLId != null){
gettingWhatIDType = URLId.getSObjectType();
String sEncodeID = EncodingUtil.base64Encode(blob.valueof(URLId+'-713ABP-XSH48-37VPK3J'));
if(gettingWhatIDType == PreEmploy_Case__c.sObjectType){
sUrl = Salesforcecl.GetSidesDotNetUrl() + 'AlternateName.aspx?ci='+sEncodeID ;
}
else{
sUrl = Salesforcecl.GetSidesDotNetUrl() + 'AlternateName.aspx?oi='+sEncodeID ;
}
}
}
}
And my test class is
@isTest
public class AlternateNamecl_Test{
static void testPageMethods() {
Alternate_Names__c an = new Alternate_Names__c();
insert an;
PageReference pRef = Page.CaseAlternateName;
pRef.getParameters().put('id', an.Id);
Test.setCurrentPage(pRef);
Test.startTest();
ApexPages.StandardController controller = new ApexPages.StandardController(an);
AlternateNamecl oAdd = new AlternateNamecl(controller);
Test.stopTest();
}
}
Add testMethod in your method. Change --> static void testPageMethods() to --> static testMethod void testPageMethods()
Hope this will helpful :)