C#C
C#16mo ago
Jasonnn

✅ Nullable<int> and xUnit

I'm writing unit tests for a method that has
int?
as a return type.

When I do:
Assert.Equal(null, parser.GetNumber(myArguments));
xUnit tells me
xUnit2003: Do not use Assert. Equal() to check for null value. Use Assert.Null instead.

When I do
Assert.Null(parser.GetNumber(myArguments));
It tells me
xUnit2002: Do not use Assert.Null() on value type 'int'. Remove this assert.

What is happening? What should I do?
Was this page helpful?