public static IsTrue ( bool expression ) : void | ||
expression | bool | a boolean expression. |
Résultat | void |
public void IsTrueValidExpression() { AssertUtils.IsTrue(true); }
/// <summary> /// Tokenize the given <see cref="System.String"/> into a /// <see cref="System.String"/> array. /// </summary> /// <remarks> /// <p> /// If <paramref name="s"/> is <see langword="null"/>, returns an empty /// <see cref="System.String"/> array. /// </p> /// <p> /// If <paramref name="delimiters"/> is <see langword="null"/> or the empty /// <see cref="System.String"/>, returns a <see cref="System.String"/> array with one /// element: <paramref name="s"/> itself. /// </p> /// </remarks> /// <param name="s">The <see cref="System.String"/> to tokenize.</param> /// <param name="delimiters"> /// The delimiter characters, assembled as a <see cref="System.String"/>. /// </param> /// <param name="trimTokens"> /// Trim the tokens via <see cref="System.String.Trim()"/>. /// </param> /// <param name="ignoreEmptyTokens"> /// Omit empty tokens from the result array. /// </param> /// <param name="quoteChars"> /// Pairs of quote characters. <paramref name="delimiters"/> within a pair of quotes are ignored /// </param> /// <returns>An array of the tokens.</returns> public static string[] Split( string s, string delimiters, bool trimTokens, bool ignoreEmptyTokens, string quoteChars) { if (s == null) { return(new string[0]); } if (string.IsNullOrEmpty(delimiters)) { return(new string[] { s }); } if (quoteChars == null) { quoteChars = string.Empty; } AssertUtils.IsTrue(quoteChars.Length % 2 == 0, "the number of quote characters must be even"); char[] delimiterChars = delimiters.ToCharArray(); // scan separator positions int[] delimiterPositions = new int[s.Length]; int count = MakeDelimiterPositionList(s, delimiterChars, quoteChars, delimiterPositions); List <string> tokens = new List <string>(count + 1); int startIndex = 0; for (int ixSep = 0; ixSep < count; ixSep++) { string token = s.Substring(startIndex, delimiterPositions[ixSep] - startIndex); if (trimTokens) { token = token.Trim(); } if (!(ignoreEmptyTokens && token.Length == 0)) { tokens.Add(token); } startIndex = delimiterPositions[ixSep] + 1; } // add remainder if (startIndex < s.Length) { string token = s.Substring(startIndex); if (trimTokens) { token = token.Trim(); } if (!(ignoreEmptyTokens && token.Length == 0)) { tokens.Add(token); } } else if (startIndex == s.Length) { if (!(ignoreEmptyTokens)) { tokens.Add(string.Empty); } } return(tokens.ToArray()); }
public void IsTrue() { Assert.Throws <ArgumentException>(() => AssertUtils.IsTrue(false), "[Assertion failed] - this expression must be true"); }
public void IsTrueWithMessageValidExpression() { AssertUtils.IsTrue(true, "foo"); }
public void IsTrueWithMesssage() { Assert.Throws <ArgumentException>(() => AssertUtils.IsTrue(false, "foo"), "foo"); }
public void IsTrue() { AssertUtils.IsTrue(false); }
public void IsTrueWithMesssage() { AssertUtils.IsTrue(false, "foo"); }