Skip to content

Commit

Permalink
PERFORMANCE: Boxing issue causing issue with some unit tests that wer…
Browse files Browse the repository at this point in the history
…e using AreEqual with bool. Added overloads of AreEqual that accept bool to cover the project systemically without changing tests. (#261, #295)
  • Loading branch information
NightOwl888 committed Jun 17, 2020
1 parent a7f7c40 commit a54545d
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,46 @@ public static void AreEqual(object expected, object actual)
public static void AreEqual(object expected, object actual, string message, params object[] args)
{
MSTest.Assert.AreEqual(expected, actual, message, args);
}
//
// Summary:
// Verifies that two objects are equal. Two objects are considered equal if both
// are null, or if both have the same value. NUnit has special semantics for some
// object types. If they are not equal an NUnit.Framework.AssertionException is
// thrown.
//
// Parameters:
// expected:
// The value that is expected
//
// actual:
// The actual value
public static void AreEqual(bool expected, bool actual)
{
MSTest.Assert.IsTrue(expected.Equals(actual));
}
//
// Summary:
// Verifies that two objects are equal. Two objects are considered equal if both
// are null, or if both have the same value. NUnit has special semantics for some
// object types. If they are not equal an NUnit.Framework.AssertionException is
// thrown.
//
// Parameters:
// expected:
// The value that is expected
//
// actual:
// The actual value
//
// message:
// The message to display in case of failure
//
// args:
// Array of objects to be used in formatting the message
public static void AreEqual(bool expected, bool actual, string message, params object[] args)
{
MSTest.Assert.IsTrue(expected.Equals(actual), message, args);
}
//
// Summary:
Expand Down
40 changes: 40 additions & 0 deletions src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,46 @@ public static void AreEqual(object expected, object actual, string message, para
}
//
// Summary:
// Verifies that two objects are equal. Two objects are considered equal if both
// are null, or if both have the same value. NUnit has special semantics for some
// object types. If they are not equal an NUnit.Framework.AssertionException is
// thrown.
//
// Parameters:
// expected:
// The value that is expected
//
// actual:
// The actual value
public static void AreEqual(bool expected, bool actual)
{
_NUnit.Assert.IsTrue(expected.Equals(actual));
}
//
// Summary:
// Verifies that two objects are equal. Two objects are considered equal if both
// are null, or if both have the same value. NUnit has special semantics for some
// object types. If they are not equal an NUnit.Framework.AssertionException is
// thrown.
//
// Parameters:
// expected:
// The value that is expected
//
// actual:
// The actual value
//
// message:
// The message to display in case of failure
//
// args:
// Array of objects to be used in formatting the message
public static void AreEqual(bool expected, bool actual, string message, params object[] args)
{
_NUnit.Assert.IsTrue(expected.Equals(actual), message, args);
}
//
// Summary:
// Verifies that two doubles are equal considering a delta. If the expected value
// is infinity then the delta value is ignored. If they are not equal then an NUnit.Framework.AssertionException
// is thrown.
Expand Down
40 changes: 40 additions & 0 deletions src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,46 @@ public static void AreEqual(object expected, object actual)
public static void AreEqual(object expected, object actual, string message, params object[] args)
{
Xunit.Assert.True(object.Equals(expected, actual), FormatMessage(message, args));
}
//
// Summary:
// Verifies that two objects are equal. Two objects are considered equal if both
// are null, or if both have the same value. NUnit has special semantics for some
// object types. If they are not equal an NUnit.Framework.AssertionException is
// thrown.
//
// Parameters:
// expected:
// The value that is expected
//
// actual:
// The actual value
public static void AreEqual(bool expected, bool actual)
{
Xunit.Assert.True(expected.Equals(actual));
}
//
// Summary:
// Verifies that two objects are equal. Two objects are considered equal if both
// are null, or if both have the same value. NUnit has special semantics for some
// object types. If they are not equal an NUnit.Framework.AssertionException is
// thrown.
//
// Parameters:
// expected:
// The value that is expected
//
// actual:
// The actual value
//
// message:
// The message to display in case of failure
//
// args:
// Array of objects to be used in formatting the message
public static void AreEqual(bool expected, bool actual, string message, params object[] args)
{
Xunit.Assert.True(expected.Equals(actual), FormatMessage(message, args));
}
//
// Summary:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ internal static void assertEquals(string message, object expected, object actual
Assert.AreEqual(expected, actual, message);
}

internal static void assertEquals(bool expected, bool actual)
{
Assert.AreEqual(expected, actual);
}

internal static void assertEquals(string message, bool expected, bool actual)
{
Assert.AreEqual(expected, actual, message);
}

internal static void assertEquals(long expected, long actual)
{
Assert.AreEqual(expected, actual);
Expand Down

0 comments on commit a54545d

Please sign in to comment.