Пример #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);
 }