Search Results for

    Show / Hide Table of Contents

    GreaterThan Constraint

    GreaterThanConstraint tests that one value is greater than another.

    Constructor

    GreaterThanConstraint(object expected)
    

    Syntax

    Is.GreaterThan(object expected)
    Is.Positive // Equivalent to Is.GreaterThan(0)
    

    Modifiers

    ...Using(IComparer comparer)
    ...Using<T>(IComparer<T> comparer)
    ...Using<T>(Comparison<T> comparer)
    ...Within(object tolerance)
    

    Examples of Use

    [Test]
    public void GreaterThan_Examples()
    {
        Assert.That(7, Is.GreaterThan(3));
        Assert.That(42, Is.Positive);
        
        DateTime expectedDateTime = DateTime.Now.AddMinutes(-1);
        DateTime myDateTime = DateTime.Now;
        Assert.That(myDateTime, Is.GreaterThan(expectedDateTime).Within(TimeSpan.FromSeconds(1)));
    }
    
    • 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