Search Results for

    Show / Hide Table of Contents

    False Constraint

    FalseConstraint tests that a value is false. Use this constraint when asserting that a boolean condition or expression evaluates to false.

    Usage

    Is.False
    Is.Not.False  // equivalent to Is.True
    

    Examples

    [Test]
    public void FalseConstraint_Examples()
    {
        Assert.That(2 + 2 == 5, Is.False);
        var isDisabled = false;
        Assert.That(isDisabled, Is.False);
        ICollection<int> list = new List<int>();
        Assert.That(list.IsReadOnly, Is.False);
    
        // With nullable booleans
        bool? isDeleted = false;
        Assert.That(isDeleted, Is.False);
    }
    

    Notes

    1. Is.Not.False is equivalent to Is.True for non-nullable booleans.
    2. For nullable booleans (bool?), Is.False only passes when the value is exactly false, not when it's null.

    See Also

    • True Constraint
    • Edit this page
    In this article
    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0