You need to sign in to do that
Don't have an account?
abhilash reddy 49
How To Write Test Classes For Custom Controller?
How to Write Test Class For Below Controller....
global class SiteLoginController1 {
public String username {get; set;}
public String password {get; set;}
public String EmpName {get;set;}
global SiteLoginController1 () {}
public boolean ErrorMsg{get;set;}
public PageReference CheckUserPswd() {
system.debug('----username----'+ username);
system.debug('----password----'+ password);
List<Employee__c> empList = [Select id, Name, User_Name__c,Password__c from Employee__c where User_Name__c =: username];
system.debug('----empList----'+ empList);
if(empList.size()>0){
if(empList[0].Password__c == password){
ErrorMsg = False;
system.debug('----'+ErrorMsg);
EmpName=empList[0].name;
system.debug('----'+EmpName);
//create a new page to enter task and associate here and also do the log off
PageReference pr=new PageReference('/apex/TimeSheetManagement?name='+EmpName);
system.debug('-----'+pr);
pr.setRedirect(true);
return pr;
}
else{
ErrorMsg = true;
return null;
}
}
else{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'No Active Employee record found with provided username.Please contact your administrator'));
return null;
}
}
Public Pagereference UpdatePasswordPage(){
PageReference newPage;
newPage = new PageReference('/apex/Forgot_Password_VF_Page');
newPage.setRedirect(true);
return newPage;
}
Public Pagereference ChangePassword(){
PageReference newPage;
EmpName=username ;
system.debug('----'+EmpName);
if(String.isEmpty(EmpName)){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Enter The User Name'));
return null;
}else{
List<Employee__c> empList = [Select id, Name, User_Name__c,Password__c from Employee__c where User_Name__c =: EmpName];
system.debug('----'+empList);
if(empList.size()==0){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Enter The Valid User Name'));
return null;
}else{
EmpName=empList[0].name;
system.debug('----'+EmpName);
newPage = new PageReference('/apex/Change_Password_Vf_Page?name='+EmpName);
newPage.setRedirect(true);
return newPage;
}
}
}
}
global class SiteLoginController1 {
public String username {get; set;}
public String password {get; set;}
public String EmpName {get;set;}
global SiteLoginController1 () {}
public boolean ErrorMsg{get;set;}
public PageReference CheckUserPswd() {
system.debug('----username----'+ username);
system.debug('----password----'+ password);
List<Employee__c> empList = [Select id, Name, User_Name__c,Password__c from Employee__c where User_Name__c =: username];
system.debug('----empList----'+ empList);
if(empList.size()>0){
if(empList[0].Password__c == password){
ErrorMsg = False;
system.debug('----'+ErrorMsg);
EmpName=empList[0].name;
system.debug('----'+EmpName);
//create a new page to enter task and associate here and also do the log off
PageReference pr=new PageReference('/apex/TimeSheetManagement?name='+EmpName);
system.debug('-----'+pr);
pr.setRedirect(true);
return pr;
}
else{
ErrorMsg = true;
return null;
}
}
else{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'No Active Employee record found with provided username.Please contact your administrator'));
return null;
}
}
Public Pagereference UpdatePasswordPage(){
PageReference newPage;
newPage = new PageReference('/apex/Forgot_Password_VF_Page');
newPage.setRedirect(true);
return newPage;
}
Public Pagereference ChangePassword(){
PageReference newPage;
EmpName=username ;
system.debug('----'+EmpName);
if(String.isEmpty(EmpName)){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Enter The User Name'));
return null;
}else{
List<Employee__c> empList = [Select id, Name, User_Name__c,Password__c from Employee__c where User_Name__c =: EmpName];
system.debug('----'+empList);
if(empList.size()==0){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Enter The Valid User Name'));
return null;
}else{
EmpName=empList[0].name;
system.debug('----'+EmpName);
newPage = new PageReference('/apex/Change_Password_Vf_Page?name='+EmpName);
newPage.setRedirect(true);
return newPage;
}
}
}
}
Raj Vakati
abhilash reddy 49
thank you rajamohan....but i am getting only 67% code coverage...