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