Assert.IsTrue Method

Definition

Overloads

IsTrue(Nullable<Boolean>, String, String)

Tests whether the specified condition is true and throws an exception if the condition is false.

IsTrue(Nullable<Boolean>, String, Object[])

Tests whether the specified condition is true and throws an exception if the condition is false.

IsTrue(Nullable<Boolean>, Assert+AssertIsTrueInterpolatedStringHandler, String)

Tests whether the specified condition is true and throws an exception if the condition is false.

IsTrue(Nullable<Boolean>, String)

Tests whether the specified condition is true and throws an exception if the condition is false.

IsTrue(Boolean, String, Object[])

Tests whether the specified condition is true and throws an exception if the condition is false.

IsTrue(Boolean, String)

Tests whether the specified condition is true and throws an exception if the condition is false.

IsTrue(Boolean, Assert+AssertIsTrueInterpolatedStringHandler)

Tests whether the specified condition is true and throws an exception if the condition is false.

IsTrue(Nullable<Boolean>)

Tests whether the specified condition is true and throws an exception if the condition is false.

IsTrue(Boolean)

Tests whether the specified condition is true and throws an exception if the condition is false.

IsTrue(Nullable<Boolean>, Assert+AssertIsTrueInterpolatedStringHandler)

Tests whether the specified condition is true and throws an exception if the condition is false.

IsTrue(Nullable<Boolean>, String, String)

Source:
Assert.IsTrue.cs

Tests whether the specified condition is true and throws an exception if the condition is false.

C#
public static void IsTrue(bool? condition, string? message = "", string conditionExpression = "");

Parameters

condition
Nullable<Boolean>

The condition the test expects to be true.

message
String

The message to include in the exception when condition is false. The message is shown in test results.

conditionExpression
String

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

Exceptions

Thrown if condition is false.

Applies to

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

IsTrue(Nullable<Boolean>, String, Object[])

Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs

Tests whether the specified condition is true and throws an exception if the condition is false.

C#
public static void IsTrue(bool? condition, string message, params object[] parameters);
C#
public static void IsTrue(bool? condition, string? message, params object?[]? parameters);

Parameters

condition
Nullable<Boolean>

The condition the test expects to be true.

message
String

The message to include in the exception when condition is false. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if condition is false.

Applies to

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

IsTrue(Nullable<Boolean>, Assert+AssertIsTrueInterpolatedStringHandler, String)

Source:
Assert.IsTrue.cs

Tests whether the specified condition is true and throws an exception if the condition is false.

C#
public static void IsTrue(bool? condition, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsTrueInterpolatedStringHandler message, string conditionExpression = "");

Parameters

condition
Nullable<Boolean>

The condition the test expects to be true.

message
Assert.AssertIsTrueInterpolatedStringHandler

The message to include in the exception when condition is false. The message is shown in test results.

conditionExpression
String

The syntactic expression of condition 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

IsTrue(Nullable<Boolean>, String)

Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs

Tests whether the specified condition is true and throws an exception if the condition is false.

C#
public static void IsTrue(bool? condition, string message);
C#
public static void IsTrue(bool? condition, string? message);

Parameters

condition
Nullable<Boolean>

The condition the test expects to be true.

message
String

The message to include in the exception when condition is false. The message is shown in test results.

Exceptions

Thrown if condition is false.

Applies to

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

IsTrue(Boolean, String, Object[])

Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs

Tests whether the specified condition is true and throws an exception if the condition is false.

C#
public static void IsTrue(bool condition, string message, params object[] parameters);
C#
public static void IsTrue(bool condition, string? message, params object?[]? parameters);

Parameters

condition
Boolean

The condition the test expects to be true.

message
String

The message to include in the exception when condition is false. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if condition is false.

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

IsTrue(Boolean, String)

Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs

Tests whether the specified condition is true and throws an exception if the condition is false.

C#
public static void IsTrue(bool condition, string message);
C#
public static void IsTrue(bool condition, string? message);

Parameters

condition
Boolean

The condition the test expects to be true.

message
String

The message to include in the exception when condition is false. The message is shown in test results.

Exceptions

Thrown if condition is false.

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

IsTrue(Boolean, Assert+AssertIsTrueInterpolatedStringHandler)

Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs

Tests whether the specified condition is true and throws an exception if the condition is false.

C#
public static void IsTrue(bool condition, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsTrueInterpolatedStringHandler message);

Parameters

condition
Boolean

The condition the test expects to be true.

message
Assert.AssertIsTrueInterpolatedStringHandler

The message to include in the exception when condition is false. 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

IsTrue(Nullable<Boolean>)

Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs

Tests whether the specified condition is true and throws an exception if the condition is false.

C#
public static void IsTrue(bool? condition);

Parameters

condition
Nullable<Boolean>

The condition the test expects to be true.

Exceptions

Thrown if condition is false.

Applies to

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

IsTrue(Boolean)

Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs

Tests whether the specified condition is true and throws an exception if the condition is false.

C#
public static void IsTrue(bool condition);

Parameters

condition
Boolean

The condition the test expects to be true.

Exceptions

Thrown if condition is false.

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

IsTrue(Nullable<Boolean>, Assert+AssertIsTrueInterpolatedStringHandler)

Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs
Source:
Assert.IsTrue.cs

Tests whether the specified condition is true and throws an exception if the condition is false.

C#
public static void IsTrue(bool? condition, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsTrueInterpolatedStringHandler message);

Parameters

condition
Nullable<Boolean>

The condition the test expects to be true.

message
Assert.AssertIsTrueInterpolatedStringHandler

The message to include in the exception when condition is false. 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