示例#1
0
        public static AssertObject PropertiesWithout <T>(this AssertObject obj, Expression <Func <T, string> > properties)
        {
            string toExclude = properties.GetMemberName();

            obj.ExcludeProperty(toExclude);
            return(obj);
        }
示例#2
0
 public static void IsGreater <T>(this AssertObject obj, T compareTo) where T : IComparable
 {
     if (!(_simpleTypeComparer.CompareGreater(obj.Subject as IComparable, compareTo) == obj.ExpectedResult))
     {
         throw new ExpectationFailedExceptin("Object is not greater");
     }
 }
示例#3
0
 public static void Eq(this AssertObject obj, object compareTo)
 {
     if (CheckComplexWithProperties(obj))
     {
         if (!(_complexTypeComparer.CompareEqualProperties(obj.Subject, compareTo, obj.PropertyToExclude)
               == obj.ExpectedResult))
         {
             throw new ExpectationFailedExceptin("Objects are not equal");
         }
     }
     else if (CheckComplex(obj))
     {
         if (!(_complexTypeComparer.CompareEqual(obj.Subject, compareTo) == obj.ExpectedResult))
         {
             throw new ExpectationFailedExceptin("Objects are not equal");
         }
     }
     else if (obj.Subject.GetType().IsPrimitive)
     {
         if (!(_simpleTypeComparer.CompareEqual(obj.Subject, compareTo) == obj.ExpectedResult))
         {
             throw new ExpectationFailedExceptin("Objects are not equal");
         }
     }
 }
示例#4
0
        public static void RaiseError(this AssertObject parent)
        {
            if (parent.Subject is Delegate)
            {
                try
                {
                    (parent.Subject as Delegate).Method.Invoke((parent.Subject as Delegate).Target, null);
                }
                catch (Exception)
                {
                    return;
                }

                throw new ExpectationFailedExceptin("Expected exception");
            }
        }
示例#5
0
 public static AssertObject Properties(this AssertObject parent)
 {
     parent.CheckProperties = true;
     return(parent);
 }
示例#6
0
 public static AssertObject Not(this AssertObject obj)
 {
     obj.ExpectedResult = false;
     return(obj);
 }
示例#7
0
 private static bool CheckComplexWithProperties(AssertObject obj)
 {
     return(!obj.Subject.GetType().IsPrimitive&& obj.CheckProperties);
 }
示例#8
0
 private static bool CheckComplex(AssertObject obj)
 {
     return(!obj.Subject.GetType().IsPrimitive);
 }