Example #1
0
 internal static void CheckParameterNotNull(object param, string assertionName, string parameterName, string message, params object[] parameters)
 {
     if (param == null)
     {
         HandleFail(assertionName, FrameworkMessages.NullParameterToAssert(new object[] { parameterName, message }), parameters);
     }
 }
Example #2
0
 public static void AreNotEqual(float notExpected, float actual, float delta, string message, params object[] parameters)
 {
     if (Math.Abs((float)(notExpected - actual)) <= delta)
     {
         string finalMessage = FrameworkMessages.AreNotEqualDeltaFailMsg(new object[] { (message == null) ? string.Empty : ReplaceNulls(message), notExpected.ToString(CultureInfo.CurrentCulture.NumberFormat), actual.ToString(CultureInfo.CurrentCulture.NumberFormat), delta.ToString(CultureInfo.CurrentCulture.NumberFormat) });
         HandleFail("Assert.AreNotEqual", finalMessage, parameters);
     }
 }
Example #3
0
 public static void AreNotEqual <T>(T notExpected, T actual, string message, params object[] parameters)
 {
     if (object.Equals(notExpected, actual))
     {
         string finalMessage = FrameworkMessages.AreNotEqualFailMsg(new object[] { (message == null) ? string.Empty : ReplaceNulls(message), ReplaceNulls(notExpected), ReplaceNulls(actual) });
         HandleFail("Assert.AreNotEqual", finalMessage, parameters);
     }
 }
Example #4
0
 public static void AreNotEqual(string notExpected, string actual, bool ignoreCase, CultureInfo culture, string message, params object[] parameters)
 {
     CheckParameterNotNull(culture, "Assert.AreNotEqual", "culture", string.Empty, new object[0]);
     if (string.Compare(notExpected, actual, culture, ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None) == 0)
     {
         string finalMessage = FrameworkMessages.AreNotEqualFailMsg(new object[] { (message == null) ? string.Empty : ReplaceNulls(message), ReplaceNulls(notExpected), ReplaceNulls(actual) });
         HandleFail("Assert.AreNotEqual", finalMessage, parameters);
     }
 }
Example #5
0
 public static void IsNotInstanceOfType(object value, Type wrongType, string message, params object[] parameters)
 {
     if (wrongType == null)
     {
         HandleFail("Assert.IsNotInstanceOfType", message, parameters);
     }
     if ((value != null) && wrongType.IsInstanceOfType(value))
     {
         string finalMessage = FrameworkMessages.IsNotInstanceOfFailMsg(new object[] { (message == null) ? string.Empty : ReplaceNulls(message), wrongType.ToString(), value.GetType().ToString() });
         HandleFail("Assert.IsNotInstanceOfType", finalMessage, parameters);
     }
 }
Example #6
0
 public static void IsInstanceOfType(Type expectedType, object value, string message, params object[] parameters)
 {
     if (expectedType == null)
     {
         HandleFail("Assert.IsInstanceOfType", message, parameters);
     }
     if (!expectedType.IsInstanceOfType(value))
     {
         string finalMessage = FrameworkMessages.IsInstanceOfFailMsg(new object[] { (message == null) ? string.Empty : ReplaceNulls(message), expectedType.ToString(), (value == null) ? "(null)" : value.GetType().ToString() });
         HandleFail("Assert.IsInstanceOfType", finalMessage, parameters);
     }
 }
Example #7
0
 public static void AreSame(object expected, object actual, string message, params object[] parameters)
 {
     if (!object.ReferenceEquals(expected, actual))
     {
         string finalMessage = message;
         if ((expected is ValueType) && (actual is ValueType))
         {
             finalMessage = FrameworkMessages.AreSameGivenValues(new object[] { (message == null) ? string.Empty : ReplaceNulls(message) });
         }
         HandleFail("Assert.AreSame", finalMessage, parameters);
     }
 }
Example #8
0
        public static void Inconclusive(string message, params object[] parameters)
        {
            string finalMessage = string.Empty;

            if (!string.IsNullOrEmpty(message))
            {
                if (parameters == null)
                {
                    finalMessage = ReplaceNulls(message);
                }
                else
                {
                    finalMessage = string.Format(CultureInfo.CurrentCulture, ReplaceNulls(message), parameters);
                }
            }
            throw new AssertInconclusiveException(FrameworkMessages.AssertionFailed(new object[] { "Assert.Inconclusive", finalMessage }));
        }
Example #9
0
        internal static void HandleFail(string assertionName, string message, params object[] parameters)
        {
            string finalMessage = string.Empty;

            if (!string.IsNullOrEmpty(message))
            {
                if (parameters == null)
                {
                    finalMessage = ReplaceNulls(message);
                }
                else
                {
                    finalMessage = string.Format(CultureInfo.CurrentCulture, ReplaceNulls(message), parameters);
                }
            }
            throw new AssertFailedException(FrameworkMessages.AssertionFailed(new object[] { assertionName, finalMessage }));
        }
Example #10
0
        public static void AreEqual <T>(T expected, T actual, string message, params object[] parameters)
        {
            if (object.Equals(CheckValue(expected), CheckValue(actual)))
            {
                return;
            }
            string finalMessage;

            if (((actual != null) && (expected != null)) && !actual.GetType().Equals(expected.GetType()))
            {
                finalMessage = FrameworkMessages.AreEqualDifferentTypesFailMsg(new object[] { (message == null) ? string.Empty : ReplaceNulls(message), ReplaceNulls(expected), expected.GetType().FullName, ReplaceNulls(actual), actual.GetType().FullName });
            }
            else
            {
                finalMessage = FrameworkMessages.AreEqualFailMsg(new object[] { (message == null) ? string.Empty : ReplaceNulls(message), ReplaceNulls(expected), ReplaceNulls(actual) });
            }
            HandleFail("Assert.AreEqual", finalMessage, parameters);
        }
Example #11
0
        public static void Fail(object expected, object actual)
        {
            string finalMessage = FrameworkMessages.AreEqualFailMsg(new object[] { "", ReplaceNulls(expected), ReplaceNulls(actual) });

            Fail(finalMessage);
        }