You need to sign in to do that
Don't have an account?
saad mechiche alami
Invalid Type Error message for a unit Test
Hello , I am currently making a unit Test to see if my Class is working properly, but i get an Invalid Type on the unit Test in this line
here is my Class followed by my unit Test:
And here is my Unit Test
Any help would be very much appreciated.
cut_off_controler coc = new cutt_off_controler();
here is my Class followed by my unit Test:
public with sharing class cut_off_controler { public string cutoff {get; set;} public cut_off_controler (ApexPages.StandardController order){ setcutoff(); } //tranform the cuttoff time (4pm cet) to local user time public void setcutoff(){ //get the user's timezone string usertz = string.valueof(userinfo.getTimeZone()); time cuttime; //get the current time in gmt and tranform it to hour //convert the gmt time to paris time tranform it to hour DateTime dateingmt = datetime.now(); String datehourParis = dateingmt.format('HH','Europe/Paris'); String datehourgmt = dateingmt.format('HH','GMT'); system.debug('date gmt' + dateingmt ); system.debug('date hour gmt' + datehourgmt ); system.debug('date hour paris' + datehourParis ); integer hourgmt = integer.valueOf(datehourgmt); integer hourparis = integer.valueOf(datehourParis); //get the difference bewteen the gmt et paris time to know if we are in summer or spring time integer zone = hourparis - hourgmt; system.debug('date zone' + zone); //if we are in summer time / spring time adjuste the cutt off time consequently if(zone == 2){ cuttime = time.newInstance(14, 0, 0, 0); }else{ cuttime = time.newInstance(15, 0, 0, 0); } //create the datetime DateTime datetoconvert = Datetime.newInstanceGmt(Date.today(), cuttime); system.debug('----------------------->datetoconvert'+datetoconvert); //Convert it to the local user timezone cutoff = datetoconvert.format('h:mm a', usertz); system.debug('----------------------->cutoff'+cutoff); } }
And here is my Unit Test
@IsTest public with sharing class cut_off_controlerTest { @IsTest(SeeAllData = false) public static void test_cut_off_controllerLondon(){ User user = new User(alias = 'usertst1', email='usertst1' + '@xyz.com', emailencodingkey='UTF-8', lastname='Testing1', languagelocalekey='en_US', localesidkey='en_US', profileid = profile.Id, timezonesidkey='Europe/London', username='user1' + '@xyz.com'); insert user; cut_off_controler coc = new cutt_off_controler(); coc.setcutoff(); } public static void test_cut_off_controllerLondon(){ User user = new User(alias = 'usertst2', email='usertst2' + '@xyz.com', emailencodingkey='UTF-8', lastname='Testing2', languagelocalekey='en_US', localesidkey='en_US', profileid = profile.Id, timezonesidkey='Asia/Shanghai', username='user2' + '@xyz.com'); insert user; cut_off_controler coc = new cutt_off_controler(); coc.setcutoff(); } }
Any help would be very much appreciated.
Many Thanks
cut_off_controler coc = new cut_off_controler();
if the answer helped you to resolve your issue, kindly mark a best answer..
Thanks