You need to sign in to do that
Don't have an account?
how to write testmethod
Hi ALL, how to write test method for the following code..
global class InboundLinxUserRegistration {
global class dtRegistrationInput {
webservice ID UserId;
webservice String First_Name;
webservice String Last_Name;
webservice String Email_Address;
webservice String Status;
webservice ID Workplace_Id;
webservice String Workplace_Name;
webservice String Workplace_Province;
webservice String Workplace_City;
webservice String Workplace_Postal_Code;
webservice String Workplace_Address;
webservice String Speciality;
webservice String Record_Type;
}
global class dtRegistrationOutput {
webservice date mydate;
webservice String added;
webservice String status;
webservice String Message_Text;
webservice String error;
}
public webservice static dtRegistrationOutput registration(dtRegistrationInput userregistration){
dtRegistrationOutput registration=new dtRegistrationOutput();
List<Account> account = [select National_Code__c,PersonEmail from Account where National_Code__c=:userregistration.UserId OR PersonEmail=:userregistration.Email_Address];
if(account.size()>0){
registration.mydate=system.today();
registration.added='false, http status code=200';
registration.error='Duplicate';
}else{
Account acc=new Account();
acc.National_Code__c=userregistration.UserId;
acc.FirstName=userregistration.First_Name;
acc.LastName=userregistration.Last_Name;
acc.PersonEmail=userregistration.Email_Address;
acc.Account_Status_NES__c=userregistration.Status;
acc.Primary_Parent_vod__c=userregistration.Workplace_Id;
acc.Primary_Province_NES__c=userregistration.Workplace_Province;
acc.Primary_City_NES__c=userregistration.Workplace_City;
acc.Primary_Postal_Code_NES__c=userregistration.Workplace_Postal_Code;
acc.Primary_Address_1_NES__c=userregistration.Workplace_Address;
acc.Specialty_1_vod__c=userregistration.Speciality;
acc.RecordTypeId=userregistration.Record_Type;
try{
insert acc;
registration.mydate=system.today();
registration.added='True,http status code=200';
registration.Message_Text='Registration Successfull';
} catch (Exception e){
registration.mydate=system.today();
registration.added='false';
registration.error=e.getTypeName();
registration.Message_Text=e.getMessage();
}
}
return registration;
}
}
Check out this post. http://boards.developerforce.com/t5/Visualforce-Development/Test-method-webservice-call-outs/td-p/175392
General information on building tests can be found here: http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
If you are getting stuck with a particular aspect of writing the test please post your attempt at the test code and the error your getting.
Hi,
Please check out this link
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
Sridhar Bonagiri