using NUnit.Framework;
namespace System.Utility
{
///
/// Utility code to make testing easier.
///
public static class AssertExtensions
{
///
/// Performs the same job as
/// but prints out a pre-formatted message using .
///
/// The types being compared.
/// The actual value.
/// The value that is expected.
/// The name of the values being compared (such as the
/// name of the property, method, etc.).
public static void IsEqualTo(this T actual, T expected, string name)
{
Assert.AreEqual(expected, actual, $"The value returned by '{name}' was not the expected value.");
}
///
/// Performs the same job as
/// but prints out a pre-formatted message using .
///
/// The types being compared.
/// The actual value.
/// The value that is not expected.
/// The name of the values being compared (such as the
/// name of the property, method, etc.).
public static void IsNotEqualTo(this T actual, T notExpected, string name)
{
Assert.AreNotEqual(notExpected, actual, $"The value returned by '{name}' was not the expected value.");
}
///
/// Performs the same job as
/// but prints out a pre-formatted message using .
///
/// The actual value.
/// The name of the values being compared (such as the
/// name of the property, method, etc.).
public static void IsTrue(this bool actual, string name)
{
Assert.IsTrue(actual, $"The value returned by '{name}' was expected to be true.");
}
///
/// Performs the same job as
/// but prints out a pre-formatted message using .
///
/// The actual value.
/// The name of the values being compared (such as the
/// name of the property, method, etc.).
public static void IsFalse(this bool actual, string name)
{
Assert.IsFalse(actual, $"The value returned by '{name}' was expected to be false.");
}
}
}