/// <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 not of the given type.</exception> public ICheckLink <IStructCheck <T> > IsInstanceOf <U>() where U : struct { this.structChecker.ExecuteCheck( () => IsInstanceHelper.IsInstanceOf(this.Value, typeof(U)), IsInstanceHelper.BuildErrorMessage(this.Value, typeof(U), true)); return(new CheckLink <IStructCheck <T> >(this)); }
/// <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 <TimeSpan> > IsInstanceOf <T>(this IFluentAssertion <TimeSpan> fluentAssertion) { var assertionRunner = fluentAssertion as IFluentAssertionRunner <TimeSpan>; var runnableAssertion = fluentAssertion as IRunnableAssertion <TimeSpan>; return(assertionRunner.ExecuteAssertion( () => { IsInstanceHelper.IsInstanceOf(runnableAssertion.Value, typeof(T)); }, IsInstanceHelper.BuildErrorMessage(runnableAssertion.Value, typeof(T), 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> /// <returns> /// A chainable fluent assertion. /// </returns> /// <exception cref="FluentAssertionException">The actual instance is not of the provided type.</exception> public IChainableFluentAssertion <IFluentAssertion <N> > IsInstanceOf <T>() { var assertionRunner = this.fluentAssertion as IFluentAssertionRunner <N>; var runnableAssertion = this; return(assertionRunner.ExecuteAssertion( () => { IsInstanceHelper.IsInstanceOf(runnableAssertion.Value, typeof(T)); }, IsInstanceHelper.BuildErrorMessage(runnableAssertion, typeof(T), true))); }