Ejemplo n.º 1
0
        /// <summary>
        /// Asserts the two given <see cref="IGenericValueContainer"/> instances are equal.
        /// </summary>
        /// <param name="expected">The expected value.</param>
        /// <param name="actual">The actual value.</param>
        /// <param name="errorMessage">Message to prefix to assertion failures.</param>
        public static void AreEqual(IGenericValueContainer expected, IGenericValueContainer actual, string errorMessage)
        {
            if (expected == null)
            {
                Assert.IsNull(actual, string.Format("{0}  actual value was not null but expected value was.", errorMessage));
            }

            Assert.IsNotNull(actual, string.Format("{0}  actual value was null but expected value was not.", errorMessage));

            Assert.AreEqual(expected.GetType(), actual.GetType(), string.Format("{0}  actual value was not of the same type as the expected.", errorMessage));

            object expectedValue = expected.GetValue();
            object actualValue   = actual.GetValue();

            AreEqual(expectedValue, actualValue, errorMessage);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Asserts the two given <see cref="IGenericValueContainer"/> instances are equal.
        /// </summary>
        /// <param name="expected">The expected value.</param>
        /// <param name="actual">The actual value.</param>
        /// <param name="errorMessage">Message to prefix to assertion failures.</param>
        public static void AreEqual(IGenericValueContainer expected, IGenericValueContainer actual, string errorMessage)
        {
            if (expected == null)
            {
                Assert.IsNull(actual, string.Format("{0}  actual value was not null but expected value was.", errorMessage));
            }

            Assert.IsNotNull(actual, string.Format("{0}  actual value was null but expected value was not.", errorMessage));

            Assert.AreEqual(expected.GetType(), actual.GetType(), string.Format("{0}  actual value was not of the same type as the expected.", errorMessage));

            object expectedValue = expected.GetValue();
            object actualValue = actual.GetValue();

            AreEqual(expectedValue, actualValue, errorMessage);
        }