예제 #1
0
 public static IAction <TResult> AsAction <TResult>(this IGivenCommand <TResult> command)
 {
     return(new CommandAction <TResult>(
                new GivenCommandAsAction <TResult>(command),
                Reporting.ActionContext.Given
                ));
 }
예제 #2
0
        /// <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));
        }
예제 #3
0
        public GivenCommandAsAction(IGivenCommand <TResult> command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            Command = command;
        }
예제 #4
0
        /// <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));
        }
예제 #5
0
        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);
        }
예제 #6
0
 public GivenCommandAsAction(IGivenCommand <TResult> command)
 {
     Command = command ?? throw new ArgumentNullException(nameof(command));
 }
예제 #7
0
 public static IAction <TResult> AsAction <TResult>(this IGivenCommand <TResult> command) => new GivenCommandAsAction <TResult>(command);