/Utilities/Assert.cs
C# | 884 lines | 525 code | 63 blank | 296 comment | 66 complexity | 310b436865472530fc64a4b10db4774f MD5 | raw file
Possible License(s): Apache-2.0
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Runtime.Serialization;
- using Delta.Utilities.Helpers;
- using NUnit.Framework;
-
- namespace Delta.Utilities
- {
- /// <summary>
- /// Assert helper class for testing and debugging. Provides static methods
- /// that help you figuring out if values are equal, not equal, less, greater,
- /// true, false, etc. This way xUnit, NUnit, etc. is not required and we can
- /// make sure all unit tests can be executed on all supported platforms.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static class Assert
- {
- #region AssertException Class
- /// <summary>
- /// Assert exception, this is just a very simple exception. Can be derived
- /// and used for other exceptions too (sometimes used for testing too).
- /// </summary>
- [Serializable]
- public sealed class AssertException : Exception
- {
- #region LineNumber (Public)
- /// <summary>
- /// The number of the code line where this exception has happened.
- /// </summary>
- public string LineNumber
- {
- get;
- private set;
- }
- #endregion
-
- #region Constructors
- /// <summary>
- /// Create assert exception with just an assert message.
- /// We use mostly just this constructor to display the message string.
- /// </summary>
- /// <param name="setMessage">Message describing the problem</param>
- public AssertException(string setMessage)
- : base(setMessage)
- {
- }
-
- /// <summary>
- /// Create assert exception with both an assert message and an inner
- /// exception. Usually used when something very bad happened and we even
- /// need to display the inner exception.
- /// </summary>
- /// <param name="setMessage">Message describing the problem</param>
- /// <param name="setInnerException">Inner exception</param>
- public AssertException(string setMessage, Exception setInnerException)
- : base(setMessage, setInnerException)
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the System.Exception class with
- /// serialized data. This is required e.g. for serializing an exception
- /// from another worker domain.
- /// </summary>
- /// <remarks>
- /// This constructor will be called after the public constructor.
- /// </remarks>
- /// <param name="info">
- /// Serialization info to pass to the base Exception.
- /// </param>
- /// <param name="context">Context for the base Exception</param>
- private AssertException(SerializationInfo info,
- StreamingContext context)
- : base(info, context)
- {
- // To reconstruct the info about our "ExceptionLine" we are only
- // interested in the last line of the stack trace (which was build now
- // by the base class) because this contains the info at which code line
- // this exception was thrown, so grab now the name of the method name
- // of the code first
- int splitIndex = StackTrace.LastIndexOf("at ");
- string lastExceptionLine = (splitIndex != MathHelper.InvalidIndex)
- ? StackTrace.Substring(splitIndex + "at ".Length)
- : StackTrace;
-
- // but still keep the information about the code line number which is
- // important to identify which Assert it was exactly
- splitIndex = lastExceptionLine.LastIndexOf(' ');
- if (splitIndex != MathHelper.InvalidIndex)
- {
- LineNumber = lastExceptionLine.Substring(splitIndex + 1);
- }
- }
- #endregion
- }
- #endregion
-
- #region Delegates
- /// <summary>
- /// Helper delegate for the Throws method below to test if code throws
- /// a specific exception. Same delegate as Base.RunDelegate, but we have
- /// no access to that one here.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public delegate void ThrowsDelegate();
- #endregion
-
- #region Equals (Static)
- /// <summary>
- /// Equals, just trying to hide it. The Equals() method is not officially
- /// supported for 'Assert', please use the 'Equal()' method instead.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new static bool Equals(object objA, object objB)
- {
- return object.Equals(objA, objB);
- }
- #endregion
-
- #region ReferenceEquals (Static)
- /// <summary>
- /// Hide method. The 'ReferenceEquals()' method is not officially
- /// supported for 'Assert', please use the 'Equal()' method instead.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new static bool ReferenceEquals(object objA, object objB)
- {
- return object.ReferenceEquals(objA, objB);
- }
- #endregion
-
- #region Equal (Static)
- /// <summary>
- /// Are two values equal? All they need is some comparer (see IsEqual).
- /// Throws an AssertException if the values are not equal. Note: Other
- /// unit test frameworks use expected and actual values for the parameters
- /// here, but we don't care about the order, usually it is programmed in
- /// a natural way so you just say Assert.Equal(Numbers.Add(10, 7), 17),
- /// but you can also do it the xUnit/NUnit way: Assert.Equal(17,
- /// Numbers.Add(10, 7).
- /// </summary>
- /// <typeparam name="T">Type to compare</typeparam>
- /// <param name="firstValue">First value</param>
- /// <param name="secondValue">Second value</param>
- /// <exception cref="AssertException">Exception is thrown if two values
- /// are not equal</exception>
- public static void Equal<T>(T firstValue, T secondValue)
- {
- if (IsEqual(firstValue, secondValue) == false)
- {
- throw new AssertException(
- "The two values were not equal: '" + firstValue + "' was not " +
- "equal to '" + secondValue + "'.");
- }
- }
- #endregion
-
- #region NotEqual (Static)
- /// <summary>
- /// These values should not be equal, if they are an exception is thrown.
- /// </summary>
- /// <param name="firstValue">Expected value</param>
- /// <param name="secondValue">Actual value</param>
- public static void NotEqual<T>(T firstValue, T secondValue)
- {
- if (IsEqual(firstValue, secondValue))
- {
- throw new AssertException(
- "The two values were equal, but they should be different: '" +
- firstValue + "' was equal to '" + secondValue + "'!");
- }
- }
- #endregion
-
- #region NearlyEqual (Static)
- /// <summary>
- /// Nearly equal check, pretty much the same as the Equal check above,
- /// but it only allows floats and it will still return true if
- /// expectedValue and actualValue are less than given max. difference.
- /// </summary>
- /// <param name="firstValue">First parameter to compare</param>
- /// <param name="secondValue">Second parameter to compare</param>
- /// <param name="maxDifference">
- /// Maximum difference allowed, MathHelper.Epsilon by default.
- /// </param>
- public static void NearlyEqual(float firstValue, float secondValue,
- float maxDifference = MathHelper.Epsilon)
- {
- float difference = Math.Abs(secondValue - firstValue);
- if (difference > maxDifference)
- {
- throw new AssertException(
- "The two values were not nearly equal: '" + firstValue + "' and '" +
- secondValue + "' (max. difference is '" + maxDifference + "')");
- }
- }
- #endregion
-
- #region Between (Static)
- /// <summary>
- /// Checks if valueToCheck is in between lowerLimit and upperLimit,
- /// lowerLimit must be smaller than upperLimit!
- /// </summary>
- /// <param name="valueToCheck">Value we want to check that should be
- /// between lowerLimit and upperLimit (both exclusive)</param>
- /// <param name="lowerLimit">Lower limit value</param>
- /// <param name="upperLimit">Upper limit value</param>
- public static void Between(float valueToCheck, float lowerLimit,
- float upperLimit)
- {
- if (lowerLimit > upperLimit)
- {
- throw new ArgumentException(
- "Why is lowerLimit '" + lowerLimit + "' bigger than upperLimit '" +
- upperLimit + "'? Please make sure lowerLimit is a smaller value " +
- "than upperLimit.");
- }
- if (valueToCheck < lowerLimit ||
- valueToCheck > upperLimit)
- {
- throw new AssertException(
- "The value '" + valueToCheck + "' is not in between '" + lowerLimit +
- "' and '" + upperLimit + "'.");
- }
- }
- #endregion
-
- #region Contains (Static)
- /// <summary>
- /// Simple string contains check that allows strings to be case-insensitive.
- /// Will throw an AssertException if expectedInString is not found in
- /// fullString. Note: Currently only supports strings, but this way
- /// we save one intellisense space (else we have 2 Contains methods).
- /// </summary>
- /// <typeparam name="T">Type to compare</typeparam>
- /// <param name="expectedInString">String value we search for</param>
- /// <param name="fullString">The string where expectedInString should be
- /// contained somewhere</param>
- public static void Contains<T>(T fullString, T expectedInString)
- {
- string expectedInStringValue = expectedInString as string;
- string fullStringValue = fullString as string;
-
- if (expectedInStringValue == null ||
- fullStringValue == null)
- {
- throw new ArithmeticException(
- "You are only allowed to call this method with 2 strings");
- }
-
- // Note: We don't have the StringHelper here, so we need to do this
- // by hand.
- else if (fullStringValue.ToLower().Contains(
- expectedInStringValue.ToLower()) == false)
- {
- throw new AssertException(
- "The string '" + expectedInString + "' was expected to be found " +
- "in '" + fullString + "', but it is just not in there.");
- }
- }
-
- /// <summary>
- /// Contains check for any IEnumerable (array, list, etc.). Will fail
- /// with an AssertException if the expectedValue is not in someArray.
- /// </summary>
- /// <typeparam name="T">Type to compare</typeparam>
- /// <param name="someArray">Some Array</param>
- /// <param name="expectedValue">Expected Value</param>
- public static void Contains<T>(IEnumerable<T> someArray, T expectedValue)
- {
- if (someArray == null)
- {
- throw new NullReferenceException(
- "Provided array is null!\n" +
- "Array needs to be initialized for checking 'Contains'.");
- }
-
- foreach (T arrayValue in someArray)
- {
- if (arrayValue.Equals(expectedValue))
- {
- return;
- }
- }
-
- throw new AssertException(
- "The value '" + expectedValue + "' was expected to be found in the " +
- "array '" + someArray + "', but it is just not in there.");
- }
- #endregion
-
- #region Throws (Static)
- /// <summary>
- /// Expects the testCode to throw an exception of exceptionType and catches
- /// it (no exception is thrown to the caller), if it does not throw the
- /// specified exceptionType, an AssertException is thrown.
- /// </summary>
- /// <param name="exceptionType">Exception Type</param>
- /// <param name="testCode">Test Code</param>
- /// <exception cref="AssertException">
- /// This is thrown if the code does not throw the expected exception.
- /// </exception>
- public static void Throws(Type exceptionType, ThrowsDelegate testCode)
- {
- try
- {
- testCode();
- throw new AssertException(
- "Expected an '" + exceptionType + "', but the code succeeded.");
- }
- catch (Exception ex)
- {
- if (exceptionType.Equals(ex.GetType()) == false &&
- // Also allow derived exception types
- exceptionType.IsInstanceOfType(ex) == false)
- {
- throw new AssertException(
- "Expected an '" + exceptionType + "', but got an '" +
- ex.GetType() + "'", ex);
- }
- }
- // Else everything is fine!
- }
- #endregion
-
- #region True (Static)
- /// <summary>
- /// Simple check if a condition is true. Since we do not know why this
- /// failed (if it is not true), you can optionally supply a why string!
- /// </summary>
- /// <param name="expectedTrueValue">
- /// Expected value that should be true
- /// </param>
- /// <exception cref="AssertException">
- /// If the value was not 'true' as expected!
- /// </exception>
- public static void True(bool expectedTrueValue)
- {
- if (expectedTrueValue != true)
- {
- throw new AssertException("The value was not 'true' as expected");
- }
- }
-
- /// <summary>
- /// Simple check if a condition is true. Since we do not know why this
- /// failed (if it is not true), you can optionally supply a why string!
- /// </summary>
- /// <param name="expectedTrueValue">
- /// Expected value that should be true.
- /// </param>
- /// <param name="why">
- /// Extra string to explain why this is wrong
- /// </param>
- /// <exception cref="AssertException">
- /// If the value was not 'true' as expected!
- /// </exception>
- public static void True(bool expectedTrueValue, string why)
- {
- if (expectedTrueValue != true)
- {
- throw new AssertException(
- "The value was not 'true' as expected" +
- (why != null
- ? ": " + why
- : ""));
- }
- }
- #endregion
-
- #region False (Static)
- /// <summary>
- /// Simple check if a condition is false. Since we do not know why this
- /// failed (if it is not false), you can optionally supply a why string!
- /// </summary>
- /// <param name="expectedFalseValue">
- /// Expected value that should be false.
- /// </param>
- /// <exception cref="AssertException">
- /// If the value was not 'false' as expected!
- /// </exception>
- public static void False(bool expectedFalseValue)
- {
- if (expectedFalseValue)
- {
- throw new AssertException("The value was not 'false' as expected");
- }
- }
-
- /// <summary>
- /// Simple check if a condition is false. Since we do not know why this
- /// failed (if it is not false), you can optionally supply a why string!
- /// </summary>
- /// <param name="expectedFalseValue">
- /// Expected value that should be false.
- /// </param>
- /// <param name="why">
- /// Why did this happen? Optional extra information text that will be added
- /// when the expectedFalseValue is not false.
- /// </param>
- /// <exception cref="AssertException">
- /// If the value was not 'false' as expected!
- /// </exception>
- public static void False(bool expectedFalseValue, string why)
- {
- if (expectedFalseValue)
- {
- throw new AssertException(
- "The value was not 'false' as expected" +
- (why != null
- ? ": " + why
- : ""));
- }
- }
- #endregion
-
- #region Null (Static)
- /// <summary>
- /// Simple check if a value is null.
- /// </summary>
- /// <param name="expectedNullValue">
- /// Expected value that should be null.
- /// </param>
- /// <exception cref="AssertException">
- /// If the value was not 'null' as expected!
- /// </exception>
- public static void Null(object expectedNullValue)
- {
- if (expectedNullValue != null)
- {
- throw new AssertException(
- "The value was expected to be 'null': " + expectedNullValue);
- }
- }
- #endregion
-
- #region NotNull (Static)
- /// <summary>
- /// Simple check if a condition is false. Since we do not know why this
- /// failed (if it is not false), you must supply a why string!
- /// </summary>
- /// <param name="expectedValue">
- /// Expected value that should not be null
- /// </param>
- /// <exception cref="AssertException">
- /// If the value was 'null', but we expected a not 'null' value!
- /// </exception>
- public static void NotNull(object expectedValue)
- {
- if (expectedValue == null)
- {
- throw new AssertException(
- "The value was expected not to be 'null'!");
- }
- }
- #endregion
-
- #region Methods (Private)
-
- #region IsEqual
- /// <summary>
- /// Helper method to figure out if two values are equal.
- /// Value types can easily be compared via Equals, reference types have to
- /// be from the same type and then we try to compare them IComparable, then
- /// IEquatable and finally checking if enumerating works. If all fails we
- /// still can fallback to the Equals method (same as for value types), but
- /// this usually fails if two references are not exactly the same pointer.
- /// </summary>
- /// <exception cref="AssertException">
- /// Exception if the two types are not equal (can be different types,
- /// different values, different lists lengths, etc.)
- /// </exception>
- private static bool IsEqual<T>(T A, T B)
- {
- // Value types can easily be compared via Equals
- Type objectType = typeof(T);
- // Class types need some extra checking
- if (objectType.IsValueType == false)
- {
- // Is normally "null" for classes
- Object defaultValue = default(T);
- // If is A == null ?
- if (Object.Equals(A, defaultValue))
- {
- // and B == null ?
- if (Object.Equals(B, defaultValue))
- {
- // the A and B are equal (-> null)
- return true;
- }
-
- // -> A == null and B != null
- return false;
- }
-
- if (Object.Equals(B, defaultValue))
- {
- // -> B == null and A != null
- return false;
- }
- }
-
- // At first we have to check the IComparable implementation (if exists)
- // -> generic
- IComparable<T> genericComparer = A as IComparable<T>;
- if (genericComparer != null)
- {
- return genericComparer.CompareTo(B) == 0;
- }
- // -> non-generic
- IComparable comparer = A as IComparable;
- if (comparer != null)
- {
- return comparer.CompareTo(B) == 0;
- }
-
- // At second the if is a IEquatable interface implemented for checking the
- // equality
- IEquatable<T> equatable = A as IEquatable<T>;
- if (equatable != null)
- {
- return equatable.Equals(B);
- }
-
- // In the case we have two lists, let's check the elements in there for
- // equality
- IEnumerable aEnumerable = A as IEnumerable;
- IEnumerable bEnumerable = B as IEnumerable;
- if (aEnumerable != null &&
- bEnumerable != null)
- {
- IEnumerator aEnumerator = A as IEnumerator;
- IEnumerator bEnumerator = B as IEnumerator;
- // Also check if we got an IList here
- if (aEnumerator == null ||
- bEnumerator == null)
- {
- ICollection aCollection = A as ICollection;
- ICollection bCollection = B as ICollection;
-
- if (aCollection == null ||
- bCollection == null)
- {
- return A.Equals(B);
- } // if
-
- if (aCollection.Count !=
- bCollection.Count)
- {
- throw new AssertException(
- "The element count of the two lists were not equal: '" +
- aCollection.Count + "' was not equal to '" + bCollection.Count +
- "'.");
- } // else if
-
- aEnumerator = aCollection.GetEnumerator();
- bEnumerator = bCollection.GetEnumerator();
- }
-
- int elementIndex = -1;
- do
- {
- elementIndex++;
- bool hadANext = aEnumerator.MoveNext();
- bool hadBNext = bEnumerator.MoveNext();
-
- // End reached?
- if (hadANext == false ||
- hadBNext == false)
- {
- // if one list is longer than the other one, they can't be equal
- return hadANext == hadBNext;
- }
- } while (Object.Equals(aEnumerator.Current, bEnumerator.Current));
-
- // The objects in the list are different
- throw new AssertException(
- "The element of the two lists at index '" + elementIndex +
- "' was not equal: '" + aEnumerator.Current + "' is not equal to '" +
- bEnumerator.Current + "'.");
- }
-
- // If the type of the value types doesn't match, we can't compare it
- // because "StructA" can be totally different to "StructB" then it's
- // not allowed to derive value types
- if (A.GetType() !=
- B.GetType())
- {
- return false;
- }
-
- // If there is really no "compare interface", then let's just check by
- // the default (object) comparer
- return A.Equals(B);
- }
- #endregion
-
- #endregion
-
- /// <summary>
- /// Tests, which can be tested with Delta.Tools.TestRunner.
- /// </summary>
- internal class AssertTests
- {
- #region Contains (LongRunning)
- /// <summary>
- /// Contains. Note: Too slow for a dynamic unit test.
- /// </summary>
- [Test, NUnit.Framework.Category("LongRunning")]
- public void Contains()
- {
- // Is some string in another one?
- Assert.Contains("Chin contain the word hi", "hi");
-
- // And test if it can fail too
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.Contains("a", "b");
- });
- // Try with switched parameters, should fail too!
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.Contains("hi", "Chin contain the word hi");
- });
-
- // Next test the collection method
- Assert.Contains(new[]
- {
- 1, 2, 3
- }, 1);
- Assert.Contains(new[]
- {
- "a", "b", "c"
- }, "b");
- List<int> someList = new List<int>();
- someList.Add(359);
- someList.Add(984);
- Assert.Contains(someList, 984);
-
- // And finally some fail checks
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.Contains(someList, 123);
- });
-
- // This fails too because "hi" is not equal to "hi there"
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.Contains(new[]
- {
- "hi there", "whattup"
- }, "hi");
- });
- }
- #endregion
-
- #region Throws (LongRunning)
- /// <summary>
- /// Throws. Note: Too slow for a dynamic unit test.
- /// </summary>
- [Test]
- [NUnit.Framework.Category("LongRunning")]
- public void Throws()
- {
- // Testing to throw some expected exceptions
- Assert.Throws(typeof(NullReferenceException), delegate
- {
- throw new NullReferenceException("Shit happens");
- });
- Assert.Throws(typeof(NullReferenceException), delegate
- {
- object nullObject = null;
- // Crashes here
- nullObject.ToString();
- });
- Assert.Throws(typeof(AssertException), delegate
- {
- // This throws AssertException because 1 is not equal to 2
- Assert.Equal(1, 2);
- });
-
- // We can also cascade Assert.Throws to check the opposite
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.Throws(typeof(Exception), delegate
- {
- // The following code does NOT throw an exception and will
- // therefore fail the Assert.Throws, which throws the
- // AssertException caught above.
- string abc = "abc";
- abc += "def";
- });
- });
-
- // Throwing the wrong exception will also fail
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.Throws(typeof(InvalidOperationException), delegate
- {
- throw new NullReferenceException("Again?");
- });
- });
-
- // However, throwing something from a derived exception should work
- Assert.Throws(typeof(Exception), delegate
- {
- throw new NullReferenceException("Seems we like this one ..");
- });
- }
- #endregion
-
- #region NearlyEqual (LongRunning)
- /// <summary>
- /// Nearly equal
- /// </summary>
- [Test]
- [NUnit.Framework.Category("LongRunning")]
- public void NearlyEqual()
- {
- // Just checking some equal values
- Assert.NearlyEqual(1, 1);
- Assert.NearlyEqual(1.25f, 1.25f);
- // Next check some different values, that are nearly equal
- Assert.NearlyEqual(1.00002f, 1.00001f);
- Assert.NearlyEqual((float)Math.Asin(Math.Sin(0.5f)), 0.5f);
-
- // We expect an exception if the different values are not equal
- Assert.Throws(typeof(AssertException), delegate
- {
- // This difference is just too big!
- Assert.NearlyEqual(1.2f, 1.1f);
- });
- }
- #endregion
-
- #region Between
- /// <summary>
- /// Between
- /// </summary>
- [Test]
- public void Between()
- {
- // 1 is between 0 and 2
- Assert.Between(1, 0, 2);
- // 54.43 is between 50 and 60
- Assert.Between(54.43f, 50, 60);
- // Also check if it can fail
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.Between(44.43f, 50, 60);
- });
- }
- #endregion
-
- #region Equal
- /// <summary>
- /// Is equal
- /// </summary>
- [Test]
- public void Equal()
- {
- // Just checking some doubles
- Assert.Equal(3.0, 3.0);
- // "null" references
- Assert.Equal(null, (Object)null);
- // and strings for equality
- Assert.Equal("Test", "Test");
-
- // We expect an exception if the different values are not equal
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.Equal(3.0, 1.0);
- });
-
- Assert.Equal(new float[]
- {
- 2, 3, 4, 5
- },
- new float[]
- {
- 2, 3, 4, 5
- });
- }
- #endregion
-
- #region False
- /// <summary>
- /// False
- /// </summary>
- [Test]
- public void False()
- {
- Assert.False(false, "False is always false");
- Assert.False(1 == 2, "Self build non-equal check");
- // And try to fail too
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.False(2 == 2, "Self build non-equal check failing");
- });
- }
- #endregion
-
- #region NotEqual
- /// <summary>
- /// Not equal
- /// </summary>
- [Test]
- public void NotEqual()
- {
- // Just checking some ints
- Assert.NotEqual(1, 3);
- // reference types
- Assert.NotEqual(new Object(), null);
- // and strings for non-equality
- Assert.NotEqual("TEst", "Test");
-
- // We expect an exception if equal values will check for non-equality
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.NotEqual("Test", "Test");
- });
- }
- #endregion
-
- #region NotNull
- /// <summary>
- /// NotNull
- /// </summary>
- [Test]
- public void NotNull()
- {
- Assert.NotNull("Hi");
- const string someObject = "nag nag";
- Assert.NotNull(someObject);
- // And try to fail too
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.NotNull(null);
- });
- }
- #endregion
-
- #region Null
- /// <summary>
- /// Null
- /// </summary>
- [Test]
- public void Null()
- {
- // For same strange reason null is really null
- Assert.Null(null);
- // Objects can be null too
- string someObject = null;
- Assert.Null(someObject);
- // And try to fail too
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.Null("Hi");
- });
- }
- #endregion
-
- #region True
- /// <summary>
- /// True
- /// </summary>
- [Test]
- public void True()
- {
- Assert.True(true, "True is always true");
- Assert.True(1 == 1, "Self build equal check");
- // And try to fail too
- Assert.Throws(typeof(AssertException), delegate
- {
- Assert.True(1 == 2, "Self build equal check failing");
- });
- }
- #endregion
- }
- }
- }
-