Beispiel #1
0
        protected void InvokeAssert <T>(DelegateRet <T> action, object expected, bool match)
        {
            T result = InvokeReturn(action);

            if (match ^ Utils.ObjectEquals(result, expected))
            {
                throw new ApplicationException(
                          string.Format("{0}\nexp{1}<{2}>\ngot=<{3}> ",
                                        GetErrorPrefix(action.Method.Name),
                                        match ? "=" : "!=",
                                        Utils.ToStrings(expected),
                                        Utils.ToStrings(result)
                                        )
                          );
            }
        }
Beispiel #2
0
        protected String InvokeVerify <T>(DelegateRet <T> action, object expected, bool match)
        {
            T result = InvokeReturn(action);

            if (match ^ Utils.ObjectEquals(result, expected))
            {
                return(string.Format("KO, {0} exp{1}<{2}> got<{3}> ",
                                     GetErrorPrefix(action.Method.Name),
                                     match ? "=" : "!=",
                                     Utils.ToStrings(expected),
                                     Utils.ToStrings(result)
                                     ));
            }
            else
            {
                return("OK");
            }
        }
Beispiel #3
0
 /// <summary>Test that two objects are equal and raise an exception if the result is false</summary>
 /// <param name="expected">expected object. Can be a string, number, array...</param>
 /// <param name="current">current object. Can be a string, number, array...</param>
 /// <param name="failmessage"></param>
 public void Equals(Object expected, Object current, string failmessage = null)
 {
     if (!Utils.ObjectEquals(expected, current))
     {
         throw new ApplicationException("Assert.Equals failed!\n" + (String.IsNullOrEmpty(failmessage) ? "exp=<" + Utils.Truncate(Utils.ToStrings(expected)) + "> got=<" + Utils.Truncate(Utils.ToStrings(current)) + ">" : failmessage));
     }
 }
Beispiel #4
0
 /// <summary>Test that two objects are not equal and raise an exception if the result is false</summary>
 /// <param name="expected">expected object. Can be a string, number, array...</param>
 /// <param name="current">current object. Can be a string, number, array...</param>
 /// <param name="failmessage">Message to return if the verification fails...</param>
 public string NotEquals(Object expected, Object current, string failmessage = null) {
     if (Utils.ObjectEquals(expected, current))
         return String.IsNullOrEmpty(failmessage) ? "KO, Verify.NotEquals failed! exp=<" + Utils.Truncate(Utils.ToStrings(expected)) + "> got=<" + Utils.Truncate(Utils.ToStrings(current)) + ">" : failmessage;
     return "OK";
 }