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

            obj.ExcludeProperty(toExclude);
            return(obj);
        }
Esempio n. 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");
     }
 }
Esempio n. 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");
         }
     }
 }
Esempio n. 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");
            }
        }
Esempio n. 5
0
 public static AssertObject Properties(this AssertObject parent)
 {
     parent.CheckProperties = true;
     return(parent);
 }
Esempio n. 6
0
 public static AssertObject Not(this AssertObject obj)
 {
     obj.ExpectedResult = false;
     return(obj);
 }
Esempio n. 7
0
 private static bool CheckComplexWithProperties(AssertObject obj)
 {
     return(!obj.Subject.GetType().IsPrimitive&& obj.CheckProperties);
 }
Esempio n. 8
0
 private static bool CheckComplex(AssertObject obj)
 {
     return(!obj.Subject.GetType().IsPrimitive);
 }