Beispiel #1
0
 /// <summary>
 /// 是否为唯一的集合
 /// </summary>
 /// <typeparam name="T">类型</typeparam>
 /// <param name="list">集合</param>
 /// <param name="message">消息</param>
 public static void IsUniqueCollection <T>(IEnumerable <T> list, string message)
 {
     AssertUtil.AreEqual(list.Distinct().Count(), list.Count(), message);
 }
Beispiel #2
0
        /// <summary>
        /// 正则表达式验证
        /// </summary>
        /// <param name="input">输入字符串</param>
        /// <param name="pattern">正则表达式</param>
        /// <param name="message">异常提示信息</param>
        /// <param name="options">正则表达式配置</param>
        public static void IsValid(string input, string pattern, string message, RegexOptions options = RegexOptions.ECMAScript)
        {
            Regex regex = new Regex(pattern, options);

            AssertUtil.IsTrue(regex.IsMatch(input), message);
        }