Search Results for

    Show / Hide Table of Contents

    InstanceOfType Constraint

    InstanceOfTypeConstraint tests that an object is of the type supplied or a derived type.

    Constructor

    InstanceOfTypeConstraint(Type)
    

    Syntax

    Is.InstanceOf(Type)
    Is.InstanceOf<T>()
    

    Examples of Use

    [Test]
    public void TypeConstraint_Examples()
    {
        Assert.That("Hello", Is.TypeOf<string>());
        Assert.That("Hello", Is.TypeOf(typeof(string)));
        Assert.That("Hello", Is.InstanceOf<string>());
        Assert.That("Hello", Is.InstanceOf<object>());
        Assert.That("Hello", Is.AssignableTo<object>());
    }
    
    • 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