Fluent Assertions Documentation
In This Topic
    Nullable Types
    In This Topic

    Nullable types

    C#
    Copy Code
    short? theShort = null;
    theShort.Should().NotHaveValue();
    theShort.Should().BeNull();
    theShort.Should().Match(x => !x.HasValue || x > 0);
    
    int? theInt = 3;
    theInt.Should().HaveValue();
    theInt.Should().NotBeNull();
    
    DateTime? theDate = null;
    theDate.Should().NotHaveValue();
    theDate.Should().BeNull();