You need to sign in to do that
Don't have an account?
SUMAN KUMARI 70
how to refer pagereference method in my apex class
Hi I am new to apex and I have a requirement to write a test class for my apex class.
Please refer the class below:-
public with sharing class auth {
public String lang { get; set; }
public auth() {
String langCode = ApexPages.currentPage().getParameters().get('language');
if (langCode == 'EN' || langCode == 'ES') {
lang = langCode;
}
else {
lang = 'EN';
}
}
public PageReference changeLanguage() {
lang = (lang.equalsIgnoreCase('EN')) ? 'ES' : 'EN';
return null;
}
}
Please do help me out with this.
Thanks a lot in advance.
Please refer the class below:-
public with sharing class auth {
public String lang { get; set; }
public auth() {
String langCode = ApexPages.currentPage().getParameters().get('language');
if (langCode == 'EN' || langCode == 'ES') {
lang = langCode;
}
else {
lang = 'EN';
}
}
public PageReference changeLanguage() {
lang = (lang.equalsIgnoreCase('EN')) ? 'ES' : 'EN';
return null;
}
}
Please do help me out with this.
Thanks a lot in advance.
Please find the code below:
Thanks,
Abhishek Bansal.
All Answers
PageReference is just a return type for the method. This can be called similar to the other methods of your class. Please find the test class for your controller class below:
Please take care of the syntax errors and let me know if you face any issues with this.
Thanks,
Abhishek Bansal.
Thanks a lot , the code is working for me but it is covering only 88% and is not covering the else part. Can you please let me know how to cover that.
Please find the code below:
Thanks,
Abhishek Bansal.
Code is working fine