Salesforce Certified Platform Developer II — Question 92
A developer is writing unit tests for the following method:
public static Boolean isFreezing(String celsiusTemp){ if(String.isNotBlank(celsiusTemp) && celsiusTemp.isNumeric())
{ return Decimal.valueof(celsiusTemp) <= 0; } return null; }
Which assertion would be used in a negative test case?
Answer options
- A. System.assertEquals(true, isFreezing(null))
- B. System.assertEquals (true, isFreezing('0')
- C. System.assertEquals(null, isFreezing('asdf'))
- D. System.assertEquals(true, isFreezing('IOO'))
Correct answer: C
Explanation
The correct answer is C because passing a non-numeric string like 'asdf' to isFreezing should return null, indicating an invalid input. Options A and B would not represent negative cases since they test valid inputs or null checks that do not return null. Option D is also incorrect as 'IOO' is not numeric and should not return true.