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

            Command = command;
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 6
0
 public GivenCommandAsAction(IGivenCommand <TResult> command)
 {
     Command = command ?? throw new ArgumentNullException(nameof(command));
 }
Esempio n. 7
0
 public static IAction <TResult> AsAction <TResult>(this IGivenCommand <TResult> command) => new GivenCommandAsAction <TResult>(command);