1

I want to be able to write a unit test for when a decimal value is null and the string value is null.

private void CompareAsNumbersIfNotEmpty(decimal? actual, string expected)
{
    if (expected == null)
    {

    }else if (expected.Length > 0)
    {
        actual.Value.Should().Be(decimal.Parse(expected));
    }
    else
    {
        actual.Should().Be(decimal.Parse(expected));
    }
}
gkkkab
  • 109
  • 2
  • 7

1 Answers1

0

A decimal cannot be null. But a nullable decimal can be null.

Is the code above a test or is it a function that the test calls?

By using Unit and FluentAssertions like you are. You can use the check ...Should().NotBeNull() on any nullable type or object.