Assert.AreEqual Method

Definition

Overloads

AreEqual(String, String, Boolean, CultureInfo, String, Object[])

Tests whether the specified strings are equal and throws an exception if they are not equal.

AreEqual(String, String, Boolean, CultureInfo, String)

Tests whether the specified strings are equal and throws an exception if they are not equal.

AreEqual(String, String, Boolean, CultureInfo, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Tests whether the specified strings are equal and throws an exception if they are not equal.

AreEqual(Single, Single, Single, String, Object[])

Tests whether the specified floats are equal and throws an exception if they are not equal.

AreEqual(Int64, Int64, Int64, String, Object[])

Tests whether the specified longs are equal and throws an exception if they are not equal.

AreEqual(Double, Double, Double, String, Object[])

Tests whether the specified doubles are equal and throws an exception if they are not equal.

AreEqual(Decimal, Decimal, Decimal, String, Object[])

Tests whether the specified decimals are equal and throws an exception if they are not equal.

AreEqual(String, String, Boolean, String)

Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison.

AreEqual(String, String, Boolean, CultureInfo)

Tests whether the specified strings are equal and throws an exception if they are not equal.

AreEqual(String, String, Boolean, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison.

AreEqual(Single, Single, Single, String)

Tests whether the specified floats are equal and throws an exception if they are not equal.

AreEqual(Single, Single, Single, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Tests whether the specified floats are equal and throws an exception if they are not equal.

AreEqual(Object, Object, String, Object[])

Tests whether the specified objects are equal and throws an exception if the two objects are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42.

AreEqual(String, String, Boolean, String, Object[])

Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison.

AreEqual(Int64, Int64, Int64, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Tests whether the specified longs are equal and throws an exception if they are not equal.

AreEqual(Object, Object)

Tests whether the specified objects are equal and throws an exception if the two objects are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42.

AreEqual(Decimal, Decimal, Decimal)

Tests whether the specified decimals are equal and throws an exception if they are not equal.

AreEqual(Int64, Int64, Int64)

Tests whether the specified longs are equal and throws an exception if they are not equal.

AreEqual(Object, Object, String)

Tests whether the specified objects are equal and throws an exception if the two objects are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42.

AreEqual(Single, Single, Single)

Tests whether the specified floats are equal and throws an exception if they are not equal.

AreEqual(Double, Double, Double)

Tests whether the specified doubles are equal and throws an exception if they are not equal.

AreEqual(Decimal, Decimal, Decimal, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Tests whether the specified decimals are equal and throws an exception if they are not equal.

AreEqual(Decimal, Decimal, Decimal, String)

Tests whether the specified decimals are equal and throws an exception if they are not equal.

AreEqual(Double, Double, Double, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Tests whether the specified doubles are equal and throws an exception if they are not equal.

AreEqual(Double, Double, Double, String)

Tests whether the specified doubles are equal and throws an exception if they are not equal.

AreEqual(String, String, Boolean)

Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison.

AreEqual(Int64, Int64, Int64, String)

Tests whether the specified longs are equal and throws an exception if they are not equal.

AreEqual<T>(T, T, String)

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

AreEqual<T>(T, T, IEqualityComparer<T>, String, Object[])

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the provided comparer parameter.

AreEqual<T>(T, T, String, Object[])

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

AreEqual<T>(T, T, IEqualityComparer<T>, String)

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the provided comparer parameter.

AreEqual<T>(T, T, IEqualityComparer<T>, Assert.AssertAreEqualInterpolatedStringHandler<T>)

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the provided comparer parameter.

AreEqual<T>(IEquatable<T>, IEquatable<T>, String, Object[])

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

AreEqual<T>(T, T, IEqualityComparer<T>)

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

AreEqual<T>(IEquatable<T>, IEquatable<T>, String)

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

AreEqual<T>(IEquatable<T>, IEquatable<T>, Assert.AssertAreEqualInterpolatedStringHandler<T>)

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

AreEqual<T>(T, T)

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

AreEqual<T>(IEquatable<T>, IEquatable<T>)

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

AreEqual<T>(T, T, Assert.AssertAreEqualInterpolatedStringHandler<T>)

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

AreEqual(String, String, Boolean, CultureInfo, String, Object[])

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified strings are equal and throws an exception if they are not equal.

public static void AreEqual(string expected, string actual, bool ignoreCase, System.Globalization.CultureInfo culture, string message, params object[] parameters);
public static void AreEqual(string? expected, string? actual, bool ignoreCase, System.Globalization.CultureInfo? culture, string? message, params object?[]? parameters);
public static void AreEqual(string? expected, string? actual, bool ignoreCase, System.Globalization.CultureInfo culture, string? message, params object?[]? parameters);

Parameters

expected
String

The first string to compare. This is the string the tests expects.

actual
String

The second string to compare. This is the string produced by the code under test.

ignoreCase
Boolean

A Boolean indicating a case-sensitive or insensitive comparison. (true indicates a case-insensitive comparison.)

culture
CultureInfo

A CultureInfo object that supplies culture-specific comparison information. If culture is null, the current culture is used.

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(String, String, Boolean, CultureInfo, String)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified strings are equal and throws an exception if they are not equal.

public static void AreEqual(string expected, string actual, bool ignoreCase, System.Globalization.CultureInfo culture, string message);
public static void AreEqual(string? expected, string? actual, bool ignoreCase, System.Globalization.CultureInfo? culture, string? message);
public static void AreEqual(string? expected, string? actual, bool ignoreCase, System.Globalization.CultureInfo culture, string? message);

Parameters

expected
String

The first string to compare. This is the string the tests expects.

actual
String

The second string to compare. This is the string produced by the code under test.

ignoreCase
Boolean

A Boolean indicating a case-sensitive or insensitive comparison. (true indicates a case-insensitive comparison.)

culture
CultureInfo

A CultureInfo object that supplies culture-specific comparison information. If culture is null, the current culture is used.

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(String, String, Boolean, CultureInfo, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Source:
Assert.AreEqual.cs

Tests whether the specified strings are equal and throws an exception if they are not equal.

public static void AreEqual(string? expected, string? actual, bool ignoreCase, System.Globalization.CultureInfo culture, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertNonGenericAreEqualInterpolatedStringHandler message);

Parameters

expected
String

The first string to compare. This is the string the tests expects.

actual
String

The second string to compare. This is the string produced by the code under test.

ignoreCase
Boolean

A Boolean indicating a case-sensitive or insensitive comparison. (true indicates a case-insensitive comparison.)

culture
CultureInfo

A CultureInfo object that supplies culture-specific comparison information. If culture is null, the current culture is used.

message
Assert.AssertNonGenericAreEqualInterpolatedStringHandler

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Applies to

AreEqual(Single, Single, Single, String, Object[])

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified floats are equal and throws an exception if they are not equal.

public static void AreEqual(float expected, float actual, float delta, string message, params object[] parameters);
public static void AreEqual(float expected, float actual, float delta, string? message, params object?[]? parameters);

Parameters

expected
Single

The first float to compare. This is the float the tests expects.

actual
Single

The second float to compare. This is the float produced by the code under test.

delta
Single

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
String

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Int64, Int64, Int64, String, Object[])

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified longs are equal and throws an exception if they are not equal.

public static void AreEqual(long expected, long actual, long delta, string message, params object[] parameters);
public static void AreEqual(long expected, long actual, long delta, string? message, params object?[]? parameters);

Parameters

expected
Int64

The first long to compare. This is the long the tests expects.

actual
Int64

The second long to compare. This is the long produced by the code under test.

delta
Int64

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
String

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Double, Double, Double, String, Object[])

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified doubles are equal and throws an exception if they are not equal.

public static void AreEqual(double expected, double actual, double delta, string message, params object[] parameters);
public static void AreEqual(double expected, double actual, double delta, string? message, params object?[]? parameters);

Parameters

expected
Double

The first double to compare. This is the double the tests expects.

actual
Double

The second double to compare. This is the double produced by the code under test.

delta
Double

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
String

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Decimal, Decimal, Decimal, String, Object[])

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified decimals are equal and throws an exception if they are not equal.

public static void AreEqual(decimal expected, decimal actual, decimal delta, string message, params object[] parameters);
public static void AreEqual(decimal expected, decimal actual, decimal delta, string? message, params object?[]? parameters);

Parameters

expected
Decimal

The first decimal to compare. This is the decimal the tests expects.

actual
Decimal

The second decimal to compare. This is the decimal produced by the code under test.

delta
Decimal

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
String

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(String, String, Boolean, String)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison.

public static void AreEqual(string expected, string actual, bool ignoreCase, string message);
public static void AreEqual(string? expected, string? actual, bool ignoreCase, string? message);

Parameters

expected
String

The first string to compare. This is the string the tests expects.

actual
String

The second string to compare. This is the string produced by the code under test.

ignoreCase
Boolean

A Boolean indicating a case-sensitive or insensitive comparison. (true indicates a case-insensitive comparison.)

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(String, String, Boolean, CultureInfo)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified strings are equal and throws an exception if they are not equal.

public static void AreEqual(string expected, string actual, bool ignoreCase, System.Globalization.CultureInfo culture);
public static void AreEqual(string? expected, string? actual, bool ignoreCase, System.Globalization.CultureInfo? culture);
public static void AreEqual(string? expected, string? actual, bool ignoreCase, System.Globalization.CultureInfo culture);

Parameters

expected
String

The first string to compare. This is the string the tests expects.

actual
String

The second string to compare. This is the string produced by the code under test.

ignoreCase
Boolean

A Boolean indicating a case-sensitive or insensitive comparison. (true indicates a case-insensitive comparison.)

culture
CultureInfo

A CultureInfo object that supplies culture-specific comparison information. If culture is null, the current culture is used.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(String, String, Boolean, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Source:
Assert.AreEqual.cs

Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison.

public static void AreEqual(string? expected, string? actual, bool ignoreCase, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertNonGenericAreEqualInterpolatedStringHandler message);

Parameters

expected
String

The first string to compare. This is the string the tests expects.

actual
String

The second string to compare. This is the string produced by the code under test.

ignoreCase
Boolean

A Boolean indicating a case-sensitive or insensitive comparison. (true indicates a case-insensitive comparison.)

message
Assert.AssertNonGenericAreEqualInterpolatedStringHandler

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Applies to

AreEqual(Single, Single, Single, String)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified floats are equal and throws an exception if they are not equal.

public static void AreEqual(float expected, float actual, float delta, string message);
public static void AreEqual(float expected, float actual, float delta, string? message);

Parameters

expected
Single

The first float to compare. This is the float the tests expects.

actual
Single

The second float to compare. This is the float produced by the code under test.

delta
Single

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
String

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Single, Single, Single, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Source:
Assert.AreEqual.cs

Tests whether the specified floats are equal and throws an exception if they are not equal.

public static void AreEqual(float expected, float actual, float delta, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertNonGenericAreEqualInterpolatedStringHandler message);

Parameters

expected
Single

The first float to compare. This is the float the tests expects.

actual
Single

The second float to compare. This is the float produced by the code under test.

delta
Single

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
Assert.AssertNonGenericAreEqualInterpolatedStringHandler

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

Applies to

AreEqual(Object, Object, String, Object[])

Tests whether the specified objects are equal and throws an exception if the two objects are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42.

public static void AreEqual(object expected, object actual, string message, params object[] parameters);

Parameters

expected
Object

The first object to compare. This is the object the tests expects.

actual
Object

The second object to compare. This is the object produced by the code under test.

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(String, String, Boolean, String, Object[])

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison.

public static void AreEqual(string expected, string actual, bool ignoreCase, string message, params object[] parameters);
public static void AreEqual(string? expected, string? actual, bool ignoreCase, string? message, params object?[]? parameters);

Parameters

expected
String

The first string to compare. This is the string the tests expects.

actual
String

The second string to compare. This is the string produced by the code under test.

ignoreCase
Boolean

A Boolean indicating a case-sensitive or insensitive comparison. (true indicates a case-insensitive comparison.)

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Int64, Int64, Int64, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Source:
Assert.AreEqual.cs

Tests whether the specified longs are equal and throws an exception if they are not equal.

public static void AreEqual(long expected, long actual, long delta, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertNonGenericAreEqualInterpolatedStringHandler message);

Parameters

expected
Int64

The first long to compare. This is the long the tests expects.

actual
Int64

The second long to compare. This is the long produced by the code under test.

delta
Int64

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
Assert.AssertNonGenericAreEqualInterpolatedStringHandler

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

Applies to

AreEqual(Object, Object)

Tests whether the specified objects are equal and throws an exception if the two objects are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42.

public static void AreEqual(object expected, object actual);

Parameters

expected
Object

The first object to compare. This is the object the tests expects.

actual
Object

The second object to compare. This is the object produced by the code under test.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Decimal, Decimal, Decimal)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified decimals are equal and throws an exception if they are not equal.

public static void AreEqual(decimal expected, decimal actual, decimal delta);

Parameters

expected
Decimal

The first decimal to compare. This is the decimal the tests expects.

actual
Decimal

The second decimal to compare. This is the decimal produced by the code under test.

delta
Decimal

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Int64, Int64, Int64)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified longs are equal and throws an exception if they are not equal.

public static void AreEqual(long expected, long actual, long delta);

Parameters

expected
Int64

The first long to compare. This is the long the tests expects.

actual
Int64

The second long to compare. This is the long produced by the code under test.

delta
Int64

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Object, Object, String)

Tests whether the specified objects are equal and throws an exception if the two objects are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42.

public static void AreEqual(object expected, object actual, string message);

Parameters

expected
Object

The first object to compare. This is the object the tests expects.

actual
Object

The second object to compare. This is the object produced by the code under test.

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Single, Single, Single)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified floats are equal and throws an exception if they are not equal.

public static void AreEqual(float expected, float actual, float delta);

Parameters

expected
Single

The first float to compare. This is the float the tests expects.

actual
Single

The second float to compare. This is the float produced by the code under test.

delta
Single

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Double, Double, Double)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified doubles are equal and throws an exception if they are not equal.

public static void AreEqual(double expected, double actual, double delta);

Parameters

expected
Double

The first double to compare. This is the double the tests expects.

actual
Double

The second double to compare. This is the double produced by the code under test.

delta
Double

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Decimal, Decimal, Decimal, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Source:
Assert.AreEqual.cs

Tests whether the specified decimals are equal and throws an exception if they are not equal.

public static void AreEqual(decimal expected, decimal actual, decimal delta, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertNonGenericAreEqualInterpolatedStringHandler message);

Parameters

expected
Decimal

The first decimal to compare. This is the decimal the tests expects.

actual
Decimal

The second decimal to compare. This is the decimal produced by the code under test.

delta
Decimal

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
Assert.AssertNonGenericAreEqualInterpolatedStringHandler

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

Applies to

AreEqual(Decimal, Decimal, Decimal, String)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified decimals are equal and throws an exception if they are not equal.

public static void AreEqual(decimal expected, decimal actual, decimal delta, string message);
public static void AreEqual(decimal expected, decimal actual, decimal delta, string? message);

Parameters

expected
Decimal

The first decimal to compare. This is the decimal the tests expects.

actual
Decimal

The second decimal to compare. This is the decimal produced by the code under test.

delta
Decimal

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
String

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Double, Double, Double, Assert+AssertNonGenericAreEqualInterpolatedStringHandler)

Source:
Assert.AreEqual.cs

Tests whether the specified doubles are equal and throws an exception if they are not equal.

public static void AreEqual(double expected, double actual, double delta, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertNonGenericAreEqualInterpolatedStringHandler message);

Parameters

expected
Double

The first double to compare. This is the double the tests expects.

actual
Double

The second double to compare. This is the double produced by the code under test.

delta
Double

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
Assert.AssertNonGenericAreEqualInterpolatedStringHandler

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

Applies to

AreEqual(Double, Double, Double, String)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified doubles are equal and throws an exception if they are not equal.

public static void AreEqual(double expected, double actual, double delta, string message);
public static void AreEqual(double expected, double actual, double delta, string? message);

Parameters

expected
Double

The first double to compare. This is the double the tests expects.

actual
Double

The second double to compare. This is the double produced by the code under test.

delta
Double

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
String

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(String, String, Boolean)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison.

public static void AreEqual(string expected, string actual, bool ignoreCase);
public static void AreEqual(string? expected, string? actual, bool ignoreCase);

Parameters

expected
String

The first string to compare. This is the string the tests expects.

actual
String

The second string to compare. This is the string produced by the code under test.

ignoreCase
Boolean

A Boolean indicating a case-sensitive or insensitive comparison. (true indicates a case-insensitive comparison.)

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual(Int64, Int64, Int64, String)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified longs are equal and throws an exception if they are not equal.

public static void AreEqual(long expected, long actual, long delta, string message);
public static void AreEqual(long expected, long actual, long delta, string? message);

Parameters

expected
Int64

The first long to compare. This is the long the tests expects.

actual
Int64

The second long to compare. This is the long produced by the code under test.

delta
Int64

The required accuracy. An exception will be thrown only if actual is different than expected by more than delta.

message
String

The message to include in the exception when actual is different than expected by more than delta. The message is shown in test results.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual<T>(T, T, String)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

public static void AreEqual<T>(T expected, T actual, string message);
public static void AreEqual<T>(T? expected, T? actual, string? message);

Type Parameters

T

The type of values to compare.

Parameters

expected
T

The first value to compare. This is the value the tests expects.

actual
T

The second value to compare. This is the value produced by the code under test.

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual<T>(T, T, IEqualityComparer<T>, String, Object[])

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the provided comparer parameter.

public static void AreEqual<T>(T? expected, T? actual, System.Collections.Generic.IEqualityComparer<T>? comparer, string? message, params object?[]? parameters);

Type Parameters

T

The type of values to compare.

Parameters

expected
T

The first value to compare. This is the value the tests expects.

actual
T

The second value to compare. This is the value produced by the code under test.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> implementation to use when comparing keys, or null to use the default EqualityComparer<T>.

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual<T>(T, T, String, Object[])

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

public static void AreEqual<T>(T expected, T actual, string message, params object[] parameters);
public static void AreEqual<T>(T? expected, T? actual, string? message, params object?[]? parameters);

Type Parameters

T

The type of values to compare.

Parameters

expected
T

The first value to compare. This is the value the tests expects.

actual
T

The second value to compare. This is the value produced by the code under test.

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual<T>(T, T, IEqualityComparer<T>, String)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the provided comparer parameter.

public static void AreEqual<T>(T? expected, T? actual, System.Collections.Generic.IEqualityComparer<T>? comparer, string? message);

Type Parameters

T

The type of values to compare.

Parameters

expected
T

The first value to compare. This is the value the tests expects.

actual
T

The second value to compare. This is the value produced by the code under test.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> implementation to use when comparing keys, or null to use the default EqualityComparer<T>.

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual<T>(T, T, IEqualityComparer<T>, Assert.AssertAreEqualInterpolatedStringHandler<T>)

Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the provided comparer parameter.

public static void AreEqual<T>(T? expected, T? actual, System.Collections.Generic.IEqualityComparer<T>? comparer, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertAreEqualInterpolatedStringHandler<T> message);

Type Parameters

T

The type of values to compare.

Parameters

expected
T

The first value to compare. This is the value the tests expects.

actual
T

The second value to compare. This is the value produced by the code under test.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> implementation to use when comparing keys, or null to use the default EqualityComparer<T>.

message
Assert.AssertAreEqualInterpolatedStringHandler<T>

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Applies to

AreEqual<T>(IEquatable<T>, IEquatable<T>, String, Object[])

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

public static void AreEqual<T>(IEquatable<T>? expected, IEquatable<T>? actual, string? message, params object?[]? parameters);

Type Parameters

T

The type of values to compare.

Parameters

expected
IEquatable<T>

The first value to compare. This is the value the tests expects.

actual
IEquatable<T>

The second value to compare. This is the value produced by the code under test.

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual<T>(T, T, IEqualityComparer<T>)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

public static void AreEqual<T>(T? expected, T? actual, System.Collections.Generic.IEqualityComparer<T>? comparer);

Type Parameters

T

The type of values to compare.

Parameters

expected
T

The first value to compare. This is the value the tests expects.

actual
T

The second value to compare. This is the value produced by the code under test.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> implementation to use when comparing keys, or null to use the default EqualityComparer<T>.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual<T>(IEquatable<T>, IEquatable<T>, String)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

public static void AreEqual<T>(IEquatable<T>? expected, IEquatable<T>? actual, string? message);

Type Parameters

T

The type of values to compare.

Parameters

expected
IEquatable<T>

The first value to compare. This is the value the tests expects.

actual
IEquatable<T>

The second value to compare. This is the value produced by the code under test.

message
String

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual<T>(IEquatable<T>, IEquatable<T>, Assert.AssertAreEqualInterpolatedStringHandler<T>)

Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

public static void AreEqual<T>(IEquatable<T>? expected, IEquatable<T>? actual, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertAreEqualInterpolatedStringHandler<T> message);

Type Parameters

T

The type of values to compare.

Parameters

expected
IEquatable<T>

The first value to compare. This is the value the tests expects.

actual
IEquatable<T>

The second value to compare. This is the value produced by the code under test.

message
Assert.AssertAreEqualInterpolatedStringHandler<T>

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Applies to

AreEqual<T>(T, T)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

public static void AreEqual<T>(T expected, T actual);
public static void AreEqual<T>(T? expected, T? actual);

Type Parameters

T

The type of values to compare.

Parameters

expected
T

The first value to compare. This is the value the tests expects.

actual
T

The second value to compare. This is the value produced by the code under test.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual<T>(IEquatable<T>, IEquatable<T>)

Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs
Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

public static void AreEqual<T>(IEquatable<T>? expected, IEquatable<T>? actual);

Type Parameters

T

The type of values to compare.

Parameters

expected
IEquatable<T>

The first value to compare. This is the value the tests expects.

actual
IEquatable<T>

The second value to compare. This is the value produced by the code under test.

Exceptions

Thrown if expected is not equal to actual.

Applies to

AreEqual<T>(T, T, Assert.AssertAreEqualInterpolatedStringHandler<T>)

Source:
Assert.AreEqual.cs

Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>.

public static void AreEqual<T>(T? expected, T? actual, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertAreEqualInterpolatedStringHandler<T> message);

Type Parameters

T

The type of values to compare.

Parameters

expected
T

The first value to compare. This is the value the tests expects.

actual
T

The second value to compare. This is the value produced by the code under test.

message
Assert.AssertAreEqualInterpolatedStringHandler<T>

The message to include in the exception when actual is not equal to expected. The message is shown in test results.

Applies to