nerdexam
Salesforce

PDII · Question #93

A developer is writing unit tests for the following method: public static Boolean isFreezing(String celsiusTemp){ if(String.isNotBlank(celsiusTemp) && celsiusTemp.isNumeric()) { return…

The correct answer is C. System.assertEquals(null, isFreezing('asdf')). See the full explanation below for the reasoning.

Question

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?

Options

  • ASystem.assertEquals(true, isFreezing(null))
  • BSystem.assertEquals (true, isFreezing('0')
  • CSystem.assertEquals(null, isFreezing('asdf'))
  • DSystem.assertEquals(true, isFreezing('IOO'))

How the community answered

(32 responses)
  • A
    16% (5)
  • B
    6% (2)
  • C
    72% (23)
  • D
    6% (2)

Community Discussion

No community discussion yet for this question.

Full PDII Practice