/// <summary> /// Tests whether the specified condition is false and throws an exception /// if the condition is true. /// </summary> /// <param name="condition">The condition the test expects to be false.</param> /// <param name="message"> /// The message to include in the exception when <paramref name="condition"/> /// is true. The message is shown in test results. /// </param> /// <exception cref="AssertFailedException"> /// Thrown if <paramref name="condition"/> is true. /// </exception> public static void False(bool condition, string message = "") { if (condition) { Assert.HandleFail("Assert.False", message); } }
/// <summary> /// Tests whether the specified condition is true and throws an exception /// if the condition is false. /// </summary> /// <param name="condition">The condition the test expects to be true.</param> /// <param name="message"> /// The message to include in the exception when <paramref name="condition"/> /// is false. The message is shown in test results. /// </param> /// <exception cref="AssertFailedException"> /// Thrown if <paramref name="condition"/> is false. /// </exception> public static void True(bool condition, string message = "") { if (!condition) { Assert.HandleFail("Assert.True", message); } }
/// <summary> /// Tests whether the expected object is equal to the actual object and /// throws an exception if it is not. /// </summary> /// </summary> /// <param name="notExpected">Expected object that we do not want it to be.</param> /// <param name="actual">Actual object.</param> /// <param name="message">Message to display upon failure.</param> public static void NotEqual <T>(T notExpected, T actual) { if (Object.Equals(notExpected, actual)) { Assert.HandleFail("Assert.NotEqual", ""); } }
/// <summary> /// Tests whether the expected object is equal to the actual object and /// throws an exception if it is not. /// </summary> /// <param name="notExpected">Expected object.</param> /// <param name="actual">Actual object.</param> /// <param name="message">Message to display upon failure.</param> public static void Equal <T>(T expected, T actual) { if (!Object.Equals(expected, actual)) { Assert.HandleFail("Assert.Equal", ""); } }
/// <summary> /// Tests whether the specified object is non-null and throws an exception /// if it is null. /// </summary> /// <param name="value">The object the test expects not to be null.</param> /// <param name="message"> /// The message to include in the exception when <paramref name="value"/> /// is null. The message is shown in test results. /// </param> /// <exception cref="AssertFailedException"> /// Thrown if <paramref name="value"/> is null. /// </exception> public static void NotNull(object value) { if (value == null) { Assert.HandleFail("Assert.NotNull", ""); } }
/// <summary> /// Tests whether the expected object is equal to the actual object and /// throws an exception if it is not. /// </summary> /// <param name="notExpected">Expected object.</param> /// <param name="actual">Actual object.</param> /// <param name="message">Message to display upon failure.</param> public static void Same(object expected, object actual) { const string EXPECTED_MSG = @"Expected: [{1}]. Actual: [{2}]. {0}"; if (!Object.ReferenceEquals(expected, actual)) { Assert.HandleFail("Assert.Same", ""); } }