Skip to content

Add [NotNull] attribute on the Should() method for object assertions#2380

Merged
jnyrup merged 2 commits intofluentassertions:developfrom
0xced:Should-NotNull
Jan 14, 2024
Merged

Add [NotNull] attribute on the Should() method for object assertions#2380
jnyrup merged 2 commits intofluentassertions:developfrom
0xced:Should-NotNull

Conversation

@0xced
Copy link
Copy Markdown
Contributor

@0xced 0xced commented Oct 13, 2023

Compelling example:

[Theory]
[InlineData(true)]
[InlineData(false)]
public void Test1(bool currentUser)
{
    IPrincipal principal = currentUser ? new WindowsPrincipal(WindowsIdentity.GetCurrent()) : new ClaimsPrincipal();
    IIdentity? identity = principal.Identity;
    
    identity.Should().NotBeOfType<GenericIdentity>();
    identity.IsAuthenticated.Should().BeFalse();
}

Fixes #1115

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support c# 8 nullable reference

10 participants