|
2 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
3 | 3 |
|
4 | 4 | using System;
|
5 |
| -using System.Diagnostics.CodeAnalysis; |
6 | 5 | using System.Globalization;
|
7 |
| -using System.Reflection; |
8 |
| -using System.Runtime.CompilerServices; |
9 |
| -using System.Threading.Tasks; |
10 | 6 |
|
11 | 7 | namespace Microsoft.VisualStudio.TestTools.UnitTesting;
|
12 | 8 |
|
@@ -98,28 +94,12 @@ public static void AreEqual<T>(T? expected, T? actual, string? message, params o
|
98 | 94 | if (!object.Equals(expected, actual))
|
99 | 95 | {
|
100 | 96 | string userMessage = BuildUserMessage(message, parameters);
|
101 |
| - string finalMessage; |
102 |
| - if (actual != null && expected != null && !actual.GetType().Equals(expected.GetType())) |
103 |
| - { |
104 |
| - // This is for cases like: Assert.AreEqual(42L, 42) -> Expected: <42>, Actual: <42> |
105 |
| - finalMessage = string.Format( |
106 |
| - CultureInfo.CurrentCulture, |
107 |
| - FrameworkMessages.AreEqualDifferentTypesFailMsg, |
108 |
| - userMessage, |
109 |
| - ReplaceNulls(expected), |
110 |
| - expected.GetType().FullName, |
111 |
| - ReplaceNulls(actual), |
112 |
| - actual.GetType().FullName); |
113 |
| - } |
114 |
| - else |
115 |
| - { |
116 |
| - finalMessage = string.Format( |
| 97 | + string finalMessage = string.Format( |
117 | 98 | CultureInfo.CurrentCulture,
|
118 | 99 | FrameworkMessages.AreEqualFailMsg,
|
119 | 100 | userMessage,
|
120 | 101 | ReplaceNulls(expected),
|
121 | 102 | ReplaceNulls(actual));
|
122 |
| - } |
123 | 103 |
|
124 | 104 | ThrowAssertFailed("Assert.AreEqual", finalMessage);
|
125 | 105 | }
|
@@ -217,152 +197,6 @@ public static void AreNotEqual<T>(T? notExpected, T? actual, string? message, pa
|
217 | 197 | }
|
218 | 198 | }
|
219 | 199 |
|
220 |
| - /// <summary> |
221 |
| - /// Tests whether the specified objects are equal and throws an exception |
222 |
| - /// if the two objects are not equal. Different numeric types are treated |
223 |
| - /// as unequal even if the logical values are equal. 42L is not equal to 42. |
224 |
| - /// </summary> |
225 |
| - /// <param name="expected"> |
226 |
| - /// The first object to compare. This is the object the tests expects. |
227 |
| - /// </param> |
228 |
| - /// <param name="actual"> |
229 |
| - /// The second object to compare. This is the object produced by the code under test. |
230 |
| - /// </param> |
231 |
| - /// <exception cref="AssertFailedException"> |
232 |
| - /// Thrown if <paramref name="expected"/> is not equal to |
233 |
| - /// <paramref name="actual"/>. |
234 |
| - /// </exception> |
235 |
| - public static void AreEqual(object? expected, object? actual) |
236 |
| - { |
237 |
| - AreEqual(expected, actual, string.Empty, null); |
238 |
| - } |
239 |
| - |
240 |
| - /// <summary> |
241 |
| - /// Tests whether the specified objects are equal and throws an exception |
242 |
| - /// if the two objects are not equal. Different numeric types are treated |
243 |
| - /// as unequal even if the logical values are equal. 42L is not equal to 42. |
244 |
| - /// </summary> |
245 |
| - /// <param name="expected"> |
246 |
| - /// The first object to compare. This is the object the tests expects. |
247 |
| - /// </param> |
248 |
| - /// <param name="actual"> |
249 |
| - /// The second object to compare. This is the object produced by the code under test. |
250 |
| - /// </param> |
251 |
| - /// <param name="message"> |
252 |
| - /// The message to include in the exception when <paramref name="actual"/> |
253 |
| - /// is not equal to <paramref name="expected"/>. The message is shown in |
254 |
| - /// test results. |
255 |
| - /// </param> |
256 |
| - /// <exception cref="AssertFailedException"> |
257 |
| - /// Thrown if <paramref name="expected"/> is not equal to |
258 |
| - /// <paramref name="actual"/>. |
259 |
| - /// </exception> |
260 |
| - public static void AreEqual(object? expected, object? actual, string? message) |
261 |
| - { |
262 |
| - AreEqual(expected, actual, message, null); |
263 |
| - } |
264 |
| - |
265 |
| - /// <summary> |
266 |
| - /// Tests whether the specified objects are equal and throws an exception |
267 |
| - /// if the two objects are not equal. Different numeric types are treated |
268 |
| - /// as unequal even if the logical values are equal. 42L is not equal to 42. |
269 |
| - /// </summary> |
270 |
| - /// <param name="expected"> |
271 |
| - /// The first object to compare. This is the object the tests expects. |
272 |
| - /// </param> |
273 |
| - /// <param name="actual"> |
274 |
| - /// The second object to compare. This is the object produced by the code under test. |
275 |
| - /// </param> |
276 |
| - /// <param name="message"> |
277 |
| - /// The message to include in the exception when <paramref name="actual"/> |
278 |
| - /// is not equal to <paramref name="expected"/>. The message is shown in |
279 |
| - /// test results. |
280 |
| - /// </param> |
281 |
| - /// <param name="parameters"> |
282 |
| - /// An array of parameters to use when formatting <paramref name="message"/>. |
283 |
| - /// </param> |
284 |
| - /// <exception cref="AssertFailedException"> |
285 |
| - /// Thrown if <paramref name="expected"/> is not equal to |
286 |
| - /// <paramref name="actual"/>. |
287 |
| - /// </exception> |
288 |
| - public static void AreEqual(object? expected, object? actual, string? message, params object?[]? parameters) |
289 |
| - { |
290 |
| - AreEqual<object>(expected, actual, message, parameters); |
291 |
| - } |
292 |
| - |
293 |
| - /// <summary> |
294 |
| - /// Tests whether the specified objects are unequal and throws an exception |
295 |
| - /// if the two objects are equal. Different numeric types are treated |
296 |
| - /// as unequal even if the logical values are equal. 42L is not equal to 42. |
297 |
| - /// </summary> |
298 |
| - /// <param name="notExpected"> |
299 |
| - /// The first object to compare. This is the value the test expects not |
300 |
| - /// to match <paramref name="actual"/>. |
301 |
| - /// </param> |
302 |
| - /// <param name="actual"> |
303 |
| - /// The second object to compare. This is the object produced by the code under test. |
304 |
| - /// </param> |
305 |
| - /// <exception cref="AssertFailedException"> |
306 |
| - /// Thrown if <paramref name="notExpected"/> is equal to <paramref name="actual"/>. |
307 |
| - /// </exception> |
308 |
| - public static void AreNotEqual(object? notExpected, object? actual) |
309 |
| - { |
310 |
| - AreNotEqual(notExpected, actual, string.Empty, null); |
311 |
| - } |
312 |
| - |
313 |
| - /// <summary> |
314 |
| - /// Tests whether the specified objects are unequal and throws an exception |
315 |
| - /// if the two objects are equal. Different numeric types are treated |
316 |
| - /// as unequal even if the logical values are equal. 42L is not equal to 42. |
317 |
| - /// </summary> |
318 |
| - /// <param name="notExpected"> |
319 |
| - /// The first object to compare. This is the value the test expects not |
320 |
| - /// to match <paramref name="actual"/>. |
321 |
| - /// </param> |
322 |
| - /// <param name="actual"> |
323 |
| - /// The second object to compare. This is the object produced by the code under test. |
324 |
| - /// </param> |
325 |
| - /// <param name="message"> |
326 |
| - /// The message to include in the exception when <paramref name="actual"/> |
327 |
| - /// is equal to <paramref name="notExpected"/>. The message is shown in |
328 |
| - /// test results. |
329 |
| - /// </param> |
330 |
| - /// <exception cref="AssertFailedException"> |
331 |
| - /// Thrown if <paramref name="notExpected"/> is equal to <paramref name="actual"/>. |
332 |
| - /// </exception> |
333 |
| - public static void AreNotEqual(object? notExpected, object? actual, string? message) |
334 |
| - { |
335 |
| - AreNotEqual(notExpected, actual, message, null); |
336 |
| - } |
337 |
| - |
338 |
| - /// <summary> |
339 |
| - /// Tests whether the specified objects are unequal and throws an exception |
340 |
| - /// if the two objects are equal. Different numeric types are treated |
341 |
| - /// as unequal even if the logical values are equal. 42L is not equal to 42. |
342 |
| - /// </summary> |
343 |
| - /// <param name="notExpected"> |
344 |
| - /// The first object to compare. This is the value the test expects not |
345 |
| - /// to match <paramref name="actual"/>. |
346 |
| - /// </param> |
347 |
| - /// <param name="actual"> |
348 |
| - /// The second object to compare. This is the object produced by the code under test. |
349 |
| - /// </param> |
350 |
| - /// <param name="message"> |
351 |
| - /// The message to include in the exception when <paramref name="actual"/> |
352 |
| - /// is equal to <paramref name="notExpected"/>. The message is shown in |
353 |
| - /// test results. |
354 |
| - /// </param> |
355 |
| - /// <param name="parameters"> |
356 |
| - /// An array of parameters to use when formatting <paramref name="message"/>. |
357 |
| - /// </param> |
358 |
| - /// <exception cref="AssertFailedException"> |
359 |
| - /// Thrown if <paramref name="notExpected"/> is equal to <paramref name="actual"/>. |
360 |
| - /// </exception> |
361 |
| - public static void AreNotEqual(object? notExpected, object? actual, string? message, params object?[]? parameters) |
362 |
| - { |
363 |
| - AreNotEqual<object>(notExpected, actual, message, parameters); |
364 |
| - } |
365 |
| - |
366 | 200 | /// <summary>
|
367 | 201 | /// Tests whether the specified floats are equal and throws an exception
|
368 | 202 | /// if they are not equal.
|
|
0 commit comments