public static IAction <TResult> AsAction <TResult>(this IWhenCommand <TResult> command) { return(new CommandAction <TResult>( new WhenCommandAsAction <TResult>(command), Reporting.ActionContext.When )); }
/// <summary> /// Execute the action in the When context /// </summary> /// <param name="command">The command to execute</param> /// <typeparam name="TResult">The type returned by the action. Use the <see cref="Unit"/> to represent void actions</typeparam> public TResult When <TResult>(IWhenCommand <TResult> command) { if (command == null) { throw new ArgumentNullException(nameof(command)); } return(CreateWhenActor().Execute(command.AsAction())); }
public WhenCommandAsAction(IWhenCommand <TResult> command) { if (command == null) { throw new ArgumentNullException(nameof(command)); } Command = command; }
public void CanUse_WithLazyAbility_ExecutingWhen_WithOtherAbility_ShouldNotMaterializeValue( [Modest] Actor sut, AbilityTest ability, object otherAbility, IWhenCommand <object, Unit> whenCommand) { var lazyAbility = new Lazy <AbilityTest>(() => ability); var actual = sut.CanUse(ability).CanUse(otherAbility); //act actual.When(whenCommand); //assert Assert.False(lazyAbility.IsValueCreated); }
/// <summary> /// Execute the action in the When context /// </summary> /// <param name="command">The command to execute</param> /// <typeparam name="TResult">The type returned by the action. Use the <see cref="Unit"/> to represent void actions</typeparam> public TResult When <TResult>(IWhenCommand <TResult> command) { Guard.ForNull(command, nameof(command)); return(CreateWhenActor().Execute(command.AsAction())); }
public WhenCommandAsAction(IWhenCommand <TResult> command) { Command = command ?? throw new ArgumentNullException(nameof(command)); }
public static IAction <TResult> AsAction <TResult>(this IWhenCommand <TResult> command) => new WhenCommandAsAction <TResult>(command);