Exemplo n.º 1
0
        public override void Assert()
        {
            switch (AssertType)
            {
            case OneParamAssertTypes.IsTrue:
                AssertionHelper.ExecuteIfBool(IsTrue, FirstParam, Message);
                break;

            case OneParamAssertTypes.IsFalse:
                AssertionHelper.ExecuteIfBool(IsFalse, FirstParam, Message);
                break;

            case OneParamAssertTypes.IsEmpty:
                AssertionHelper.ExecuteIfAppropriateType <T, ICollection>(IsEmpty, FirstParam, Message);
                break;

            case OneParamAssertTypes.IsNotEmpty:
                AssertionHelper.ExecuteIfAppropriateType <T, ICollection>(IsNotEmpty, FirstParam, Message);
                break;

            case OneParamAssertTypes.IsNull:
                IsNull(FirstParam, Message);
                break;

            case OneParamAssertTypes.IsNotNull:
                IsNotNull(FirstParam, Message);
                break;

            case OneParamAssertTypes.IsZero:
                AssertionHelper.ExecuteIfNumeric(IsZero, FirstParam, Message);
                break;

            case OneParamAssertTypes.IsNotZero:
                AssertionHelper.ExecuteIfNumeric(IsNotZero, FirstParam, Message);
                break;

            case OneParamAssertTypes.IsPositive:
                AssertionHelper.ExecuteIfNumeric(IsPositive, FirstParam, Message);
                break;

            case OneParamAssertTypes.IsNegative:
                AssertionHelper.ExecuteIfNumeric(IsNegative, FirstParam, Message);
                break;

            case OneParamAssertTypes.That:
                var wasAsserted1 = AssertionHelper.ExecuteIfBool(That, FirstParam, Message, false);
                var wasAsserted2 = AssertionHelper.ExecuteIfAppropriateType <T, Func <bool> >(That, FirstParam, Message, false);
                if (!(wasAsserted1 || wasAsserted2))
                {
                    AssertionHelper.ThrowExceptionIfNeeded(true, typeof(bool), FirstParam.GetType());
                }
                break;

            case OneParamAssertTypes.Throws:
                Throws(FirstParam, Message);
                break;

            case OneParamAssertTypes.ThrowsAsync:
                ThrowsAsync(FirstParam, Message);
                break;

            default:
                ThrowExceptionIfInvalidEnumItem();
                break;
            }
        }
Exemplo n.º 2
0
        public override void Assert()
        {
            switch (AssertType)
            {
            case TwoParamsAssertTypes.AreEqual:
                AreEqual(FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.AreNotEqual:
                AreNotEqual(FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.AreSame:
                AreSame(FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.AreNotSame:
                AreNotSame(FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.Contains:
                AssertionHelper.ExecuteIfAppropriateType <object, ICollection, T1, T2>(Contains, FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.NotContains:
                AssertionHelper.ExecuteIfAppropriateType <object, ICollection, T1, T2>(NotContains, FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.Greater:
                AssertionHelper.ExecuteIfAppropriateType <IComparable, IComparable, T1, T2>(Greater, FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.GreaterOrEqual:
                AssertionHelper.ExecuteIfAppropriateType <IComparable, IComparable, T1, T2>(GreaterOrEqual, FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.Less:
                AssertionHelper.ExecuteIfAppropriateType <IComparable, IComparable, T1, T2>(Less, FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.LessOrEqual:
                AssertionHelper.ExecuteIfAppropriateType <IComparable, IComparable, T1, T2>(LessOrEqual, FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.IsAssignableFrom:
                AssertionHelper.ExecuteIfAppropriateType <Type, object, T1, T2>(IsAssignableFrom, FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.IsNotAssignableFrom:
                AssertionHelper.ExecuteIfAppropriateType <Type, object, T1, T2>(IsNotAssignableFrom, FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.IsInstanceOf:
                AssertionHelper.ExecuteIfAppropriateType <Type, object, T1, T2>(IsInstanceOf, FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.IsNotInstanceOf:
                AssertionHelper.ExecuteIfAppropriateType <Type, object, T1, T2>(IsNotInstanceOf, FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.That:
                That(FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.Throws:
                Throws(FirstParam, SecondParam, Message);
                break;

            case TwoParamsAssertTypes.ThrowsAsync:
                ThrowsAsync(FirstParam, SecondParam, Message);
                break;

            default:
                ThrowExceptionIfInvalidEnumItem();
                break;
            }
        }