Exemple #1
0
 /// <summary></summary>
 /// <param name="text"></param>
 /// <param name="value"></param>
 /// <param name="failmessage"></param>
 public void Contains(string text, string value, string failmessage = null)
 {
     if (!text.Contains(value))
     {
         throw new ApplicationException("Assert.Contains failed!\n" + (String.IsNullOrEmpty(failmessage) ? "val=<" + Utils.Truncate(text) + "> str=<" + value + ">" : failmessage));
     }
 }
Exemple #2
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));
     }
 }
Exemple #3
0
 /// <summary></summary>
 /// <param name="input"></param>
 /// <param name="pattern"></param>
 /// <param name="failmessage"></param>
 public void NotMatches(string input, string pattern, string failmessage = null)
 {
     if (Regex.IsMatch(input, pattern))
     {
         throw new ApplicationException("Assert.NotMatches failed!\n" + (String.IsNullOrEmpty(failmessage) ? "txt=<" + Utils.Truncate(input) + "> pat=<" + pattern + ">" : failmessage));
     }
 }
Exemple #4
0
 /// <summary>Get a substring of the first N characters.</summary>
 public static string Truncate(string source)
 {
     return(Utils.Truncate(source, 100));
 }
Exemple #5
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";
 }
Exemple #6
0
 /// <summary></summary>
 /// <param name="text"></param>
 /// <param name="value"></param>
 /// <param name="failmessage"></param>
 /// <returns></returns>
 public string Contains(string text, string value, string failmessage = null) {
     if (text.Contains(value))
         return "OK";
     return String.IsNullOrEmpty(failmessage) ? "KO, Verify.Contains failed! txt=<" + Utils.Truncate(text) + "> val=<" + value + ">" : failmessage;
 }
Exemple #7
0
 /// <summary></summary>
 /// <param name="text"></param>
 /// <param name="pattern"></param>
 /// <param name="failmessage"></param>
 /// <returns></returns>
 public string NotMatches(string text, string pattern, string failmessage = null) {
     if (Regex.IsMatch(text, pattern))
         return String.IsNullOrEmpty(failmessage) ? "KO, Verify.NotMatches failed! txt=<" + Utils.Truncate(text) + "> pat=<" + pattern + ">" : failmessage;
     return "OK";
 }