/// <summary> /// Initializes a new instance of the <see cref="LambdaCheck" /> class. /// </summary> /// <param name="action">The action.</param> public LambdaCheck(Delegate action) { this.runTrace = CodeCheckExtensions.GetTrace(() => { try { action.DynamicInvoke(); } catch (Exception e) { throw e.InnerException; } }); }
/// <summary> /// Returns a <see cref="ICheck{T}" /> instance that will provide check methods to be executed on a given async function (returning Task{TResult}). /// </summary> /// <typeparam name="TResult">The type of the result for this asynchronous function.</typeparam> /// <param name="awaitableFunction">The asynchronous function to be tested.</param> /// <returns> /// A <see cref="ICheck{RunTrace}" /> instance to use in order to assert things on the given value. /// </returns> /// <remarks> /// Every method of the returned <see cref="ICheck{T}" /> instance will throw a <see cref="FluentCheckException" /> when failing. /// </remarks> public static ICodeCheck <RunTraceResult <TResult> > ThatAsyncCode <TResult>(Func <Task <TResult> > awaitableFunction) { return(new FluentCodeCheck <RunTraceResult <TResult> >(CodeCheckExtensions.GetAsyncTrace(awaitableFunction))); }
/// <summary> /// Returns a <see cref="ICheck{T}" /> instance that will provide check methods to be executed on a given async code (returning Task). /// </summary> /// <param name="awaitableMethod">The async code to be tested.</param> /// <returns> /// A <see cref="ICheck{RunTrace}" /> instance to use in order to assert things on the given value. /// </returns> /// <remarks> /// Every method of the returned <see cref="ICheck{T}" /> instance will throw a <see cref="FluentCheckException" /> when failing. /// </remarks> public static ICodeCheck <RunTrace> ThatAsyncCode(Func <Task> awaitableMethod) { return(new FluentCodeCheck <RunTrace>(CodeCheckExtensions.GetAsyncTrace(awaitableMethod))); }
/// <summary> /// Returns a <see cref="ICheck{T}" /> instance that will provide check methods to be executed on a given value. /// </summary> /// <typeparam name="U">Result type of the function.</typeparam> /// <param name="value">The code to be tested.</param> /// <returns> /// A <see cref="ICheck{RunTrace}" /> instance to use in order to assert things on the given value. /// </returns> /// <remarks> /// Every method of the returned <see cref="ICheck{T}" /> instance will throw a <see cref="FluentCheckException" /> when failing. /// </remarks> public static ICodeCheck <RunTraceResult <U> > ThatCode <U>(Func <U> value) { return(new FluentCodeCheck <RunTraceResult <U> >(CodeCheckExtensions.GetTrace(value))); }
/// <summary> /// Returns a <see cref="ICheck{T}" /> instance that will provide check methods to be executed on a given value. /// </summary> /// <param name="value">The code to be tested.</param> /// <returns> /// A <see cref="ICheck{RunTrace}" /> instance to use in order to assert things on the given value. /// </returns> /// <remarks> /// Every method of the returned <see cref="ICheck{T}" /> instance will throw a <see cref="FluentCheckException" /> when failing. /// </remarks> public static ICodeCheck <RunTrace> ThatCode(Action value) { return(new FluentCodeCheck <RunTrace>(CodeCheckExtensions.GetTrace(value))); }