/// <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 null (and not of the same nullable type) or not of the given type.</exception> public ICheckLink <ICheck <T> > IsInstanceOf <TU>() { if (typeof(T).IsNullable()) { return(this.checker.ExecuteCheck( () => IsInstanceHelper.IsSameType(typeof(T), typeof(TU), this.Value), IsInstanceHelper.BuildErrorMessageForNullable(typeof(T), typeof(TU), this.Value, true))); } return(this.checker.ExecuteCheck(() => IsInstanceHelper.IsInstanceOf(this.Value, typeof(TU)), IsInstanceHelper.BuildErrorMessage(this.Value, typeof(TU), true))); }
/// <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 <int?> > IsInstanceOf <T>(this IFluentAssertion <int?> fluentAssertion) { var assertionRunner = fluentAssertion as IFluentAssertionRunner <int?>; IRunnableAssertion <int?> runnableAssertion = fluentAssertion as IRunnableAssertion <int?>; assertionRunner.ExecuteAssertion( () => { IsInstanceHelper.IsSameType(typeof(Nullable <int>), typeof(T), runnableAssertion.Value); }, IsInstanceHelper.BuildErrorMessageForNullable(typeof(Nullable <int>), typeof(T), runnableAssertion.Value, true)); return(new ChainableFluentAssertion <IFluentAssertion <int?> >(fluentAssertion)); }