Assert.IsNull Method

Definition

Overloads

IsNull(Object, String, Object[])

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

IsNull(Object, Assert+AssertIsNullInterpolatedStringHandler, String)

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

IsNull(Object, String, String)

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

IsNull(Object, String)

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

IsNull(Object)

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

IsNull(Object, Assert+AssertIsNullInterpolatedStringHandler)

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

IsNull(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
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs

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

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

Parameters

value
Object

The object the test expects to be null.

message
String

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

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if value is not null.

Applies to

MSTest.TestFramework 3.11.0 和其他版本
产品 版本
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.3, 3.9.3, 3.10.5, 3.11.0

IsNull(Object, Assert+AssertIsNullInterpolatedStringHandler, String)

Source:
Assert.IsNull.cs

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

C#
public static void IsNull(object? value, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsNullInterpolatedStringHandler message, string valueExpression = "");

Parameters

value
Object

The object the test expects to be null.

message
Assert.AssertIsNullInterpolatedStringHandler

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

valueExpression
String

The syntactic expression of value as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.

Applies to

MSTest.TestFramework 4.0.0
产品 版本
MSTest.TestFramework 4.0.0

IsNull(Object, String, String)

Source:
Assert.IsNull.cs

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

C#
public static void IsNull(object? value, string? message = "", string valueExpression = "");

Parameters

value
Object

The object the test expects to be null.

message
String

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

valueExpression
String

The syntactic expression of value as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.

Exceptions

Thrown if value is not null.

Applies to

MSTest.TestFramework 4.0.0
产品 版本
MSTest.TestFramework 4.0.0

IsNull(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
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs

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

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

Parameters

value
Object

The object the test expects to be null.

message
String

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

Exceptions

Thrown if value is not null.

Applies to

MSTest.TestFramework 3.11.0 和其他版本
产品 版本
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.3, 3.9.3, 3.10.5, 3.11.0

IsNull(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
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs
Source:
Assert.IsNull.cs

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

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

Parameters

value
Object

The object the test expects to be null.

Exceptions

Thrown if value is not null.

Applies to

MSTest.TestFramework 3.11.0 和其他版本
产品 版本
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.3, 3.9.3, 3.10.5, 3.11.0

IsNull(Object, Assert+AssertIsNullInterpolatedStringHandler)

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

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

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

Parameters

value
Object

The object the test expects to be null.

message
Assert.AssertIsNullInterpolatedStringHandler

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

Applies to

MSTest.TestFramework 3.11.0 和其他版本
产品 版本
MSTest.TestFramework 3.8.3, 3.9.3, 3.10.5, 3.11.0