Beispiel #1
0
 public static IAction <TResult> AsAction <TResult>(this IWhenCommand <TResult> command)
 {
     return(new CommandAction <TResult>(
                new WhenCommandAsAction <TResult>(command),
                Reporting.ActionContext.When
                ));
 }
Beispiel #2
0
        /// <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;
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 /// <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()));
 }
Beispiel #6
0
 public WhenCommandAsAction(IWhenCommand <TResult> command)
 {
     Command = command ?? throw new ArgumentNullException(nameof(command));
 }
Beispiel #7
0
 public static IAction <TResult> AsAction <TResult>(this IWhenCommand <TResult> command) => new WhenCommandAsAction <TResult>(command);