Assert.IsNotNull Method

Definition

Overloads

IsNotNull(Object)

Tests whether the specified object is non-null and throws an exception if it is null.

IsNotNull(Object, Assert+AssertIsNotNullInterpolatedStringHandler)

Tests whether the specified object is null and throws an exception if it is not.

IsNotNull(Object, String)

Tests whether the specified object is non-null and throws an exception if it is null.

IsNotNull(Object, String, Object[])

Tests whether the specified object is non-null and throws an exception if it is null.

IsNotNull(Object)

Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs

Tests whether the specified object is non-null and throws an exception if it is null.

C#
public static void IsNotNull(object value);
C#
public static void IsNotNull(object? value);

Parameters

value
Object

The object the test expects not to be null.

Exceptions

Thrown if value is null.

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 1.1.18, 1.2.1, 1.3.2, 1.4.0, 2.2.0, 2.1.2, 2.2.10, 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

IsNotNull(Object, Assert+AssertIsNotNullInterpolatedStringHandler)

Source:
Assert.IsNull.cs

Tests whether the specified object is null and throws an exception if it is not.

C#
public static void IsNotNull(object? value, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsNotNullInterpolatedStringHandler message);

Parameters

value
Object

The object the test expects to be null.

message
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsNotNullInterpolatedStringHandler

The message to include in the exception when value is not null. The message is shown in test results.

Applies to

MSTest.TestFramework 3.8.0
Produit Versions
MSTest.TestFramework 3.8.0

IsNotNull(Object, String)

Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs

Tests whether the specified object is non-null and throws an exception if it is null.

C#
public static void IsNotNull(object value, string message);
C#
public static void IsNotNull(object? value, string? message);

Parameters

value
Object

The object the test expects not to be null.

message
String

The message to include in the exception when value is null. The message is shown in test results.

Exceptions

Thrown if value is null.

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 1.1.18, 1.2.1, 1.3.2, 1.4.0, 2.2.0, 2.1.2, 2.2.10, 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

IsNotNull(Object, String, Object[])

Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs

Tests whether the specified object is non-null and throws an exception if it is null.

C#
public static void IsNotNull(object value, string message, params object[] parameters);
C#
public static void IsNotNull(object? value, string? message, params object?[]? parameters);

Parameters

value
Object

The object the test expects not to be null.

message
String

The message to include in the exception when value is null. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if value is null.

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 1.1.18, 1.2.1, 1.3.2, 1.4.0, 2.2.0, 2.1.2, 2.2.10, 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0