예제 #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 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)));
        }
예제 #4
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)));
        }
예제 #5
0
 /// <summary>
 /// Checks whether if the checked value is of 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 not of the given type.</exception>
 public ICheckLink <IStructCheck <T> > IsInstanceOf <TU>() where TU : struct
 {
     return(this.structChecker.ExecuteCheck(
                () => IsInstanceHelper.IsInstanceOf(this.Value, typeof(TU)),
                IsInstanceHelper.BuildErrorMessage(this.Value, typeof(TU), true)));
 }
예제 #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)));
        }
예제 #7
0
        /// <summary>
        /// Checks whether if the checked value is of 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 null (and not of the same nullable type) or not of the given type.</exception>
        public ICheckLink <ICheck <T> > IsInstanceOf <U>()
        {
            if (typeof(T).IsNullable())
            {
                this.checker.ExecuteCheck(
                    () => IsInstanceHelper.IsSameType(typeof(T), typeof(U), this.Value),
                    IsInstanceHelper.BuildErrorMessageForNullable(typeof(T), typeof(U), this.Value, true));

                return(new CheckLink <ICheck <T> >(this));
            }

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