/// <summary> /// Configure result to inject with the monkey policy. /// </summary> /// <param name="options">The configuration object.</param> /// <param name="result">A delegate representing the result to inject.</param> public static InjectOutcomeOptions <TResult> Result <TResult>(this InjectOutcomeOptions <TResult> options, Func <Context, CancellationToken, TResult> result) { options.OutcomeInternal = result; return(options); }
/// <summary> /// Configure result to inject with the monkey policy. /// </summary> /// <param name="options">The configuration object.</param> /// <param name="result">The result to inject</param> public static InjectOutcomeOptions <TResult> Result <TResult>(this InjectOutcomeOptions <TResult> options, TResult result) => Result(options, (_, __) => result);
/// <summary> /// Configure fault to inject with the monkey policy. /// </summary> /// <param name="options">The configuration object.</param> /// <param name="fault">The result to inject</param> public static InjectOutcomeOptions <Exception> Fault <TResult>(this InjectOutcomeOptions <Exception> options, Exception fault) => Fault <TResult>(options, (_, __) => fault);
/// <summary> /// Configure fault to inject with the monkey policy. /// </summary> /// <param name="options">The configuration object.</param> /// <param name="fault">A delegate representing the result to inject.</param> public static InjectOutcomeOptions <Exception> Fault <TResult>(this InjectOutcomeOptions <Exception> options, Func <Context, CancellationToken, Exception> fault) { options.OutcomeInternal = fault; return(options); }
internal InjectOutcomePolicy(InjectOutcomeOptions <Exception> options) : base(options.InjectionRate, options.Enabled) { _faultProvider = options.OutcomeInternal ?? throw new ArgumentNullException(nameof(options.OutcomeInternal)); }