You need to sign in to do that
Don't have an account?
IKZ
Test class error: Illegal assignment from String to Decimal
I’m trying to write a test class for class calculating business hours
In CaseTriggerHandler we have:
And in CaseTriggerHelper:
and in my CaseTriggerHandlerTest so far I got:
that's:
System.assertEquals(setup_data.TestUser.Id, test_case.CreatedDate != NULL);
thank you
In CaseTriggerHandler we have:
public void beforeUpdate(SObject oldSo, SObject so){ CaseTriggerHelper.calculateBusinessHours((Case)oldSo, (Case)so); }
And in CaseTriggerHelper:
public static void calculateBusinessHours(Case oldCase, Case newCase){ if (oldCase.Initial_FCO_Date__c != newCase.Initial_FCO_Date__c && newCase.Initial_FCO_Date__c != null ){ Double timeSinceLastStatus = BusinessHours.diff(newCase.BusinessHoursId, newCase.CreatedDate, newCase.Initial_FCO_Date__c)/3600000.0; newCase.Business_Hours_FCO_Created_CreateDate__c =timeSinceLastStatus; } } }
and in my CaseTriggerHandlerTest so far I got:
static testMethod void testCalculateBusinessHours() { SetupDataClass setup_data = new SetupDataClass(); setup_data.upsertTestCases(); System.runAs(setup_data.TestUser){ Test.startTest(); Case test_case = [SELECT Id, CreatedDate, Initial_FCO_Date__c, Business_Hours_FCO_Created_CreateDate__c FROM CASE WHERE Id = :setup_data.TestCase.Id]; BusinessHours calculateBusinessHours = [SELECT Id FROM BusinessHours WHERE IsDefault=true]; for(Case case_to_update : setup_data.TestCases){ case_to_update.CreatedDate = Datetime.now().addDays(-1); case_to_update.Initial_FCO_Date__c = Datetime.now(); case_to_update.Business_Hours_FCO_Created_CreateDate__c = '8.50'; Test.stopTest(); for (Case updated_case : setup_data.TestCases) { System.assertEquals(setup_data.TestUser.Id, test_case.CreatedDate != NULL); System.assertEquals(setup_data.TestUser.Id, test_case.Initial_FCO_Date__c != NULL); } } } }Error: Compile Error: Illegal assignment from String to Decimal at line 60 column 21
that's:
System.assertEquals(setup_data.TestUser.Id, test_case.CreatedDate != NULL);
thank you
Comparison arguments must be compatible types: Id, Boolean
setup_data.TestUser.Id looks like it should be an Id field and "test_case.CreatedDate != NULL" is a boolean.
System.assertEquals(setup_data.TestUser.Id, test_case.CreatedDate != NULL);
any suggestions how I can fix that?
Comparison arguments must be compatible types: Id, Boolean at line 64 column 20
64 being: System.assertEquals(setup_data.TestUser.Id, test_case.CreatedDate != NULL);