Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Assert.AreEqual/AreNotEqual overloads with object object #1429

Merged
merged 1 commit into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 1 addition & 167 deletions src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Microsoft.VisualStudio.TestTools.UnitTesting;

Expand Down Expand Up @@ -98,28 +94,12 @@ public static void AreEqual<T>(T? expected, T? actual, string? message, params o
if (!object.Equals(expected, actual))
{
string userMessage = BuildUserMessage(message, parameters);
string finalMessage;
if (actual != null && expected != null && !actual.GetType().Equals(expected.GetType()))
{
// This is for cases like: Assert.AreEqual(42L, 42) -> Expected: <42>, Actual: <42>
finalMessage = string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.AreEqualDifferentTypesFailMsg,
userMessage,
ReplaceNulls(expected),
expected.GetType().FullName,
ReplaceNulls(actual),
actual.GetType().FullName);
}
else
{
finalMessage = string.Format(
string finalMessage = string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.AreEqualFailMsg,
userMessage,
ReplaceNulls(expected),
ReplaceNulls(actual));
}

ThrowAssertFailed("Assert.AreEqual", finalMessage);
}
Expand Down Expand Up @@ -217,152 +197,6 @@ public static void AreNotEqual<T>(T? notExpected, T? actual, string? message, pa
}
}

/// <summary>
/// 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.
/// </summary>
/// <param name="expected">
/// The first object to compare. This is the object the tests expects.
/// </param>
/// <param name="actual">
/// The second object to compare. This is the object produced by the code under test.
/// </param>
/// <exception cref="AssertFailedException">
/// Thrown if <paramref name="expected"/> is not equal to
/// <paramref name="actual"/>.
/// </exception>
public static void AreEqual(object? expected, object? actual)
{
AreEqual(expected, actual, string.Empty, null);
}

/// <summary>
/// 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.
/// </summary>
/// <param name="expected">
/// The first object to compare. This is the object the tests expects.
/// </param>
/// <param name="actual">
/// The second object to compare. This is the object produced by the code under test.
/// </param>
/// <param name="message">
/// The message to include in the exception when <paramref name="actual"/>
/// is not equal to <paramref name="expected"/>. The message is shown in
/// test results.
/// </param>
/// <exception cref="AssertFailedException">
/// Thrown if <paramref name="expected"/> is not equal to
/// <paramref name="actual"/>.
/// </exception>
public static void AreEqual(object? expected, object? actual, string? message)
{
AreEqual(expected, actual, message, null);
}

/// <summary>
/// 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.
/// </summary>
/// <param name="expected">
/// The first object to compare. This is the object the tests expects.
/// </param>
/// <param name="actual">
/// The second object to compare. This is the object produced by the code under test.
/// </param>
/// <param name="message">
/// The message to include in the exception when <paramref name="actual"/>
/// is not equal to <paramref name="expected"/>. The message is shown in
/// test results.
/// </param>
/// <param name="parameters">
/// An array of parameters to use when formatting <paramref name="message"/>.
/// </param>
/// <exception cref="AssertFailedException">
/// Thrown if <paramref name="expected"/> is not equal to
/// <paramref name="actual"/>.
/// </exception>
public static void AreEqual(object? expected, object? actual, string? message, params object?[]? parameters)
{
AreEqual<object>(expected, actual, message, parameters);
}

/// <summary>
/// Tests whether the specified objects are unequal and throws an exception
/// if the two objects are equal. Different numeric types are treated
/// as unequal even if the logical values are equal. 42L is not equal to 42.
/// </summary>
/// <param name="notExpected">
/// The first object to compare. This is the value the test expects not
/// to match <paramref name="actual"/>.
/// </param>
/// <param name="actual">
/// The second object to compare. This is the object produced by the code under test.
/// </param>
/// <exception cref="AssertFailedException">
/// Thrown if <paramref name="notExpected"/> is equal to <paramref name="actual"/>.
/// </exception>
public static void AreNotEqual(object? notExpected, object? actual)
{
AreNotEqual(notExpected, actual, string.Empty, null);
}

/// <summary>
/// Tests whether the specified objects are unequal and throws an exception
/// if the two objects are equal. Different numeric types are treated
/// as unequal even if the logical values are equal. 42L is not equal to 42.
/// </summary>
/// <param name="notExpected">
/// The first object to compare. This is the value the test expects not
/// to match <paramref name="actual"/>.
/// </param>
/// <param name="actual">
/// The second object to compare. This is the object produced by the code under test.
/// </param>
/// <param name="message">
/// The message to include in the exception when <paramref name="actual"/>
/// is equal to <paramref name="notExpected"/>. The message is shown in
/// test results.
/// </param>
/// <exception cref="AssertFailedException">
/// Thrown if <paramref name="notExpected"/> is equal to <paramref name="actual"/>.
/// </exception>
public static void AreNotEqual(object? notExpected, object? actual, string? message)
{
AreNotEqual(notExpected, actual, message, null);
}

/// <summary>
/// Tests whether the specified objects are unequal and throws an exception
/// if the two objects are equal. Different numeric types are treated
/// as unequal even if the logical values are equal. 42L is not equal to 42.
/// </summary>
/// <param name="notExpected">
/// The first object to compare. This is the value the test expects not
/// to match <paramref name="actual"/>.
/// </param>
/// <param name="actual">
/// The second object to compare. This is the object produced by the code under test.
/// </param>
/// <param name="message">
/// The message to include in the exception when <paramref name="actual"/>
/// is equal to <paramref name="notExpected"/>. The message is shown in
/// test results.
/// </param>
/// <param name="parameters">
/// An array of parameters to use when formatting <paramref name="message"/>.
/// </param>
/// <exception cref="AssertFailedException">
/// Thrown if <paramref name="notExpected"/> is equal to <paramref name="actual"/>.
/// </exception>
public static void AreNotEqual(object? notExpected, object? actual, string? message, params object?[]? parameters)
{
AreNotEqual<object>(notExpected, actual, message, parameters);
}

/// <summary>
/// Tests whether the specified floats are equal and throws an exception
/// if they are not equal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,6 @@ static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(float expect
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(long expected, long actual, long delta) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(long expected, long actual, long delta, string? message) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(long expected, long actual, long delta, string? message, params object?[]? parameters) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(object? expected, object? actual) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(object? expected, object? actual, string? message) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(object? expected, object? actual, string? message, params object?[]? parameters) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(string? expected, string? actual, bool ignoreCase) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(string? expected, string? actual, bool ignoreCase, string? message) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(string? expected, string? actual, bool ignoreCase, string? message, params object?[]? parameters) -> void
Expand All @@ -264,9 +261,6 @@ static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(float not
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(long notExpected, long actual, long delta) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(long notExpected, long actual, long delta, string? message) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(long notExpected, long actual, long delta, string? message, params object?[]? parameters) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(object? notExpected, object? actual) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(object? notExpected, object? actual, string? message) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(object? notExpected, object? actual, string? message, params object?[]? parameters) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(string? notExpected, string? actual, bool ignoreCase) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(string? notExpected, string? actual, bool ignoreCase, string? message) -> void
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(string? notExpected, string? actual, bool ignoreCase, string? message, params object?[]? parameters) -> void
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@
<data name="AreEqualCaseFailMsg" xml:space="preserve">
<value>Expected:&lt;{1}&gt;. Case is different for actual value:&lt;{2}&gt;. {0}</value>
</data>
<data name="AreEqualDifferentTypesFailMsg" xml:space="preserve">
<value>Expected:&lt;{1} ({2})&gt;. Actual:&lt;{3} ({4})&gt;. {0}</value>
</data>
<data name="AreNotEqualFailMsg" xml:space="preserve">
<value>Expected any value except:&lt;{1}&gt;. Actual:&lt;{2}&gt;. {0}</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<target state="translated">Očekáváno:&lt;{1}&gt;. Případ je rozdílný pro aktuální hodnotu:&lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreEqualDifferentTypesFailMsg">
<source>Expected:&lt;{1} ({2})&gt;. Actual:&lt;{3} ({4})&gt;. {0}</source>
<target state="translated">Očekáváno:&lt;{1} ({2})&gt;. Aktuálně:&lt;{3} ({4})&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotEqualFailMsg">
<source>Expected any value except:&lt;{1}&gt;. Actual:&lt;{2}&gt;. {0}</source>
<target state="translated">Nebyla očekávána žádná hodnota kromě:&lt;{1}&gt;. Aktuálně:&lt;{2}&gt;. {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<target state="translated">Erwartet:&lt;{1}&gt;. Die Großschreibung des tatsächlichen Werts weicht davon ab:&lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreEqualDifferentTypesFailMsg">
<source>Expected:&lt;{1} ({2})&gt;. Actual:&lt;{3} ({4})&gt;. {0}</source>
<target state="translated">Erwartet:&lt;{1} ({2})&gt;. Tatsächlich:&lt;{3} ({4})&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotEqualFailMsg">
<source>Expected any value except:&lt;{1}&gt;. Actual:&lt;{2}&gt;. {0}</source>
<target state="translated">Es wurde ein beliebiger Wert erwartet außer:&lt;{1}&gt;. Tatsächlich:&lt;{2}&gt;. {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<target state="translated">Se esperaba:&lt;{1}&gt;. La caja es diferente para el valor actual:&lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreEqualDifferentTypesFailMsg">
<source>Expected:&lt;{1} ({2})&gt;. Actual:&lt;{3} ({4})&gt;. {0}</source>
<target state="translated">Se esperaba:&lt;{1} ({2})&gt;, pero es:&lt;{3} ({4})&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotEqualFailMsg">
<source>Expected any value except:&lt;{1}&gt;. Actual:&lt;{2}&gt;. {0}</source>
<target state="translated">Se esperaba cualquier valor excepto &lt;{1}&gt;, pero es &lt;{2}&gt;. {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<target state="translated">Attendu :&lt;{1}&gt;. La casse est différente pour la valeur réelle :&lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreEqualDifferentTypesFailMsg">
<source>Expected:&lt;{1} ({2})&gt;. Actual:&lt;{3} ({4})&gt;. {0}</source>
<target state="translated">Attendu : &lt;{1} ({2})&gt;, Réel : &lt;{3} ({4})&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotEqualFailMsg">
<source>Expected any value except:&lt;{1}&gt;. Actual:&lt;{2}&gt;. {0}</source>
<target state="translated">Toute valeur attendue sauf :&lt;{1}&gt;. Réel :&lt;{2}&gt;. {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<target state="translated">Previsto:&lt;{1}&gt;. La combinazione di maiuscole e minuscole è diversa per il valore effettivo:&lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreEqualDifferentTypesFailMsg">
<source>Expected:&lt;{1} ({2})&gt;. Actual:&lt;{3} ({4})&gt;. {0}</source>
<target state="translated">Previsto:&lt;{1} ({2})&gt;. Effettivo:&lt;{3} ({4})&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotEqualFailMsg">
<source>Expected any value except:&lt;{1}&gt;. Actual:&lt;{2}&gt;. {0}</source>
<target state="translated">Previsto qualsiasi valore tranne:&lt;{1}&gt;. Effettivo:&lt;{2}&gt;. {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<target state="translated">&lt;{1}&gt; が必要です。実際の値: &lt;{2}&gt; では大文字と小文字が異なります。{0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreEqualDifferentTypesFailMsg">
<source>Expected:&lt;{1} ({2})&gt;. Actual:&lt;{3} ({4})&gt;. {0}</source>
<target state="translated">&lt;{1} ({2})&gt; が必要ですが、&lt;{3} ({4})&gt; が指定されました。{0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotEqualFailMsg">
<source>Expected any value except:&lt;{1}&gt;. Actual:&lt;{2}&gt;. {0}</source>
<target state="translated">&lt;{1}&gt; 以外の任意の値が必要ですが、&lt;{2}&gt; が指定されています。{0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<target state="translated">예상 값: &lt;{1}&gt;. 대/소문자가 다른 실제 값: &lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreEqualDifferentTypesFailMsg">
<source>Expected:&lt;{1} ({2})&gt;. Actual:&lt;{3} ({4})&gt;. {0}</source>
<target state="translated">예상 값: &lt;{1} ({2})&gt;. 실제 값: &lt;{3} ({4})&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotEqualFailMsg">
<source>Expected any value except:&lt;{1}&gt;. Actual:&lt;{2}&gt;. {0}</source>
<target state="translated">예상 값: &lt;{1}&gt;을(를) 제외한 모든 값. 실제 값: &lt;{2}&gt;. {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<target state="translated">Oczekiwano:&lt;{1}&gt;. Przypadek różni się od rzeczywistej wartości:&lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreEqualDifferentTypesFailMsg">
<source>Expected:&lt;{1} ({2})&gt;. Actual:&lt;{3} ({4})&gt;. {0}</source>
<target state="translated">Oczekiwana:&lt;{1} ({2})&gt;. Rzeczywista:&lt;{3} ({4})&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotEqualFailMsg">
<source>Expected any value except:&lt;{1}&gt;. Actual:&lt;{2}&gt;. {0}</source>
<target state="translated">Oczekiwano dowolnej wartości za wyjątkiem:&lt;{1}&gt;. Rzeczywista:&lt;{2}&gt;. {0}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<target state="translated">Esperado:&lt;{1}&gt;. Capitalização é diferente para o valor real:&lt;{2}&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreEqualDifferentTypesFailMsg">
<source>Expected:&lt;{1} ({2})&gt;. Actual:&lt;{3} ({4})&gt;. {0}</source>
<target state="translated">Esperado:&lt;{1} ({2})&gt;. Real:&lt;{3} ({4})&gt;. {0}</target>
<note></note>
</trans-unit>
<trans-unit id="AreNotEqualFailMsg">
<source>Expected any value except:&lt;{1}&gt;. Actual:&lt;{2}&gt;. {0}</source>
<target state="translated">Esperado qualquer valor exceto:&lt;{1}&gt;. Real:&lt;{2}&gt;. {0}</target>
Expand Down
Loading