Example #1
0
        public void PassesOnTypeEqualsByObject()
        {
            string str1 = "123";
            string str2 = "abc";

            TypeAssert.AreEqual(str1, str2);
        }
Example #2
0
        public void PassesOnAttributeGet_generice()
        {
            Type         classType = typeof(AttrTestModel);
            PropertyInfo property  = classType.GetProperty("Name");
            var          result    = property.GetAttribute <AttrTestAttribute>();

            TypeAssert.AreEqual(typeof(AttrTestAttribute), result);
        }
Example #3
0
 /// <summary>
 /// 执行一个可能抛出异常的方法,检查抛出异常的异常是否匹配预期异常的泛型类型T
 /// </summary>
 /// <typeparam name="T">期望的异常类型</typeparam>
 /// <param name="method">执行的方法</param>
 public static void InnerException <T>(Action method)
     where T : Exception
 {
     try
     {
         method.Invoke();
     }
     catch (Exception ex)
     {
         TypeAssert.AreEqual(typeof(T), ex.InnerException);
         return;
     }
     Assert.Fail("Expected exception '" + typeof(T).FullName + "' wasn't thrown.");
 }
Example #4
0
        public void PassesOnTypeEquals_generice()
        {
            string str = "abc";

            TypeAssert.Equals <string>(str);
        }
Example #5
0
        public void PassesOnTypeEqualsByType()
        {
            string str = "abc";

            TypeAssert.AreEqual(typeof(string), str);
        }
Example #6
0
        public void PassesTypeIs_generice()
        {
            string str = "abc";

            TypeAssert.Is <object>(str);
        }