예제 #1
0
        /// <summary>
        /// Checks whether if the checked value is different from the given type.
        /// </summary>
        /// <typeparam name="U">The given type to check the checked value against.</typeparam>
        /// <returns>A chainable check.</returns>
        /// <exception cref="FluentCheckException">The specified value is of the given type.</exception>
        public ICheckLink <IStructCheck <T> > IsNotInstanceOf <U>() where U : struct
        {
            this.structChecker.ExecuteCheck(
                () => IsInstanceHelper.IsNotInstanceOf(this.Value, typeof(U)),
                IsInstanceHelper.BuildErrorMessage(this.Value, typeof(U), false));

            return(new CheckLink <IStructCheck <T> >(this));
        }
예제 #2
0
        /// <summary>
        /// Checks that the actual instance is not an instance of the given type.
        /// </summary>
        /// <typeparam name="T">The type not expected for this instance.</typeparam>
        /// <param name="fluentAssertion">The fluent assertion to be extended.</param>
        /// <returns>
        /// A chainable fluent assertion.
        /// </returns>
        /// <exception cref="FluentAssertionException">The actual instance is of the provided type.</exception>
        public static IChainableFluentAssertion <IFluentAssertion <TimeSpan> > IsNotInstanceOf <T>(this IFluentAssertion <TimeSpan> fluentAssertion)
        {
            var assertionRunner   = fluentAssertion as IFluentAssertionRunner <TimeSpan>;
            var runnableAssertion = fluentAssertion as IRunnableAssertion <TimeSpan>;

            return(assertionRunner.ExecuteAssertion(
                       () =>
            {
                IsInstanceHelper.IsNotInstanceOf(runnableAssertion.Value, typeof(T));
            },
                       IsInstanceHelper.BuildErrorMessage(runnableAssertion.Value, typeof(T), false)));
        }
예제 #3
0
        /// <summary>
        /// Checks whether if the checked value is different from the given type.
        /// </summary>
        /// <typeparam name="TU">The given type to check the checked value against.</typeparam>
        /// <returns>A chainable check.</returns>
        /// <exception cref="FluentCheckException">The specified value is of the given type.</exception>
        public ICheckLink <ICheck <T> > IsNotInstanceOf <TU>()
        {
            if (typeof(T).IsNullable())
            {
                return(this.checker.ExecuteCheck(
                           () => IsInstanceHelper.IsDifferentType(typeof(T), typeof(TU), this.Value),
                           IsInstanceHelper.BuildErrorMessageForNullable(typeof(T), typeof(TU), this.Value, false)));
            }

            return(this.checker.ExecuteCheck(
                       () => IsInstanceHelper.IsNotInstanceOf(this.Value, typeof(TU)), IsInstanceHelper.BuildErrorMessage(this.Value, typeof(TU), false)));
        }
예제 #4
0
        /// <summary>
        /// Checks that the actual instance is not an instance of the given type.
        /// </summary>
        /// <typeparam name="T">The type not expected for this instance.</typeparam>
        /// <returns>
        /// A chainable fluent assertion.
        /// </returns>
        /// <exception cref="FluentAssertionException">The actual instance is of the provided type.</exception>
        public IChainableFluentAssertion <IFluentAssertion <N> > IsNotInstanceOf <T>()
        {
            var assertionRunner   = this.fluentAssertion as IFluentAssertionRunner <N>;
            var runnableAssertion = this;

            return(assertionRunner.ExecuteAssertion(
                       () =>
            {
                IsInstanceHelper.IsNotInstanceOf(runnableAssertion.Value, typeof(T));
            },
                       IsInstanceHelper.BuildErrorMessage(runnableAssertion, typeof(T), false)));
        }
예제 #5
0
        /// <summary>
        /// Checks that the actual instance is an instance of the given type.
        /// </summary>
        /// <typeparam name="T">The expected Type of the instance.</typeparam>
        /// <param name="fluentAssertion">The fluent assertion to be extended.</param>
        /// <returns>
        /// A chainable fluent assertion.
        /// </returns>
        /// <exception cref="FluentAssertionException">The actual instance is not of the provided type.</exception>
        public static IChainableFluentAssertion <IFluentAssertion <object> > IsNotInstanceOf <T>(this IFluentAssertion <object> fluentAssertion)
        {
            var assertionRunner   = fluentAssertion as IFluentAssertionRunner <object>;
            var runnableAssertion = fluentAssertion as IRunnableAssertion <object>;

            return(assertionRunner.ExecuteAssertion(
                       () =>
            {
                IsInstanceHelper.IsNotInstanceOf(runnableAssertion.Value, typeof(T));
            },
                       string.Format("\nThe actual value:\n\t[{0}]\nis not an instance of:\n\t[{1}]\nbut an instance of:\n\t[{2}]\ninstead.", runnableAssertion.Value.ToStringProperlyFormated(), typeof(T), runnableAssertion.Value.GetType())));
        }
예제 #6
0
        /// <summary>
        /// Checks whether if the checked value is different from the given type.
        /// </summary>
        /// <typeparam name="U">The given type to check the checked value against.</typeparam>
        /// <returns>A chainable check.</returns>
        /// <exception cref="FluentCheckException">The specified value is of the given type.</exception>
        public ICheckLink <ICheck <T> > IsNotInstanceOf <U>()
        {
            if (typeof(T).IsNullable())
            {
                this.checker.ExecuteCheck(
                    () =>
                {
                    if (typeof(T) == typeof(U))
                    {
                        throw new FluentCheckException(IsInstanceHelper.BuildErrorMessageForNullable(typeof(T), typeof(U), this.Value, true));
                    }
                },
                    IsInstanceHelper.BuildErrorMessageForNullable(typeof(T), typeof(U), this.Value, false));
                return(new CheckLink <ICheck <T> >(this));
            }

            return(this.checker.ExecuteCheck(
                       () => IsInstanceHelper.IsNotInstanceOf(this.Value, typeof(U)), IsInstanceHelper.BuildErrorMessage(this.Value, typeof(U), false)));
        }