Exemple #1
0
        public ScenarioRunner(
            IScenario scenario
            , IMessageBus messageBus
            , Type scenarioClass
            , object[] constructorArguments
            , MethodInfo scenarioMethod
            , object[] scenarioMethodArguments
            , string skipReason
            , IReadOnlyList <BeforeAfterTestAttribute> beforeAfterScenarioAttributes
            , ExceptionAggregator aggregator
            , CancellationTokenSource cancellationTokenSource)
        {
            //Guard.AgainstNullArgument(nameof(scenario), scenario);
            //Guard.AgainstNullArgument(nameof(messageBus), messageBus);
            //Guard.AgainstNullArgument(nameof(aggregator), aggregator);

#if DEBUG
            scenario.RequiresNotNull(nameof(scenario));
            messageBus.RequiresNotNull(nameof(messageBus));
            aggregator.RequiresNotNull(nameof(aggregator));
#endif

            this._scenario   = scenario;
            this._messageBus = messageBus;
            // TODO: TBD: #3 MWP 2020-07-01 03:14:04 PM / should there be guards on these?
            this._scenarioClass           = scenarioClass;
            this._constructorArguments    = constructorArguments;
            this._scenarioMethod          = scenarioMethod;
            this._scenarioMethodArguments = scenarioMethodArguments;
            this._skipReason = skipReason;
            this._beforeAfterScenarioAttributes = beforeAfterScenarioAttributes;
            this._parentAggregator        = aggregator;
            this._cancellationTokenSource = cancellationTokenSource;
        }
        public StepInvoker(
            IStepContext stepContext
            , Func <IStepContext, Task> body
            , ExceptionAggregator aggregator
            , CancellationTokenSource cancellationTokenSource)
        {
            //Guard.AgainstNullArgument(nameof(aggregator), aggregator);
            //Guard.AgainstNullArgument(nameof(cancellationTokenSource), cancellationTokenSource);

#if DEBUG
            aggregator.RequiresNotNull(nameof(aggregator));
            cancellationTokenSource.RequiresNotNull(nameof(cancellationTokenSource));
#endif

            // TODO: TBD: #3 MWP 2020-07-01 03:15:09 PM / should we validate the other bits?
            this._stepContext             = stepContext;
            this._body                    = body;
            this._aggregator              = aggregator;
            this._cancellationTokenSource = cancellationTokenSource;
        }
        public ScenarioInvoker(
            IScenario scenario
            , IMessageBus messageBus
            , Type scenarioClass
            , object[] constructorArguments
            , MethodInfo scenarioMethod
            , object[] scenarioMethodArguments
            , IReadOnlyList <BeforeAfterTestAttribute> beforeAfterScenarioAttributes
            , ExceptionAggregator aggregator
            , CancellationTokenSource cancellationTokenSource)
        {
            //Guard.AgainstNullArgument(nameof(scenario), scenario);
            //Guard.AgainstNullArgument(nameof(messageBus), messageBus);
            //Guard.AgainstNullArgument(nameof(scenarioClass), scenarioClass);
            //Guard.AgainstNullArgument(nameof(scenarioMethod), scenarioMethod);
            //Guard.AgainstNullArgument(nameof(beforeAfterScenarioAttributes), beforeAfterScenarioAttributes);
            //Guard.AgainstNullArgument(nameof(aggregator), aggregator);
            //Guard.AgainstNullArgument(nameof(cancellationTokenSource), cancellationTokenSource);

#if DEBUG
            scenario.RequiresNotNull(nameof(scenario));
            messageBus.RequiresNotNull(nameof(messageBus));
            scenarioClass.RequiresNotNull(nameof(scenarioClass));
            scenarioMethod.RequiresNotNull(nameof(scenarioMethod));
            beforeAfterScenarioAttributes.RequiresNotNull(nameof(beforeAfterScenarioAttributes));
            aggregator.RequiresNotNull(nameof(aggregator));
            cancellationTokenSource.RequiresNotNull(nameof(cancellationTokenSource));
#endif

            this._scenario = scenario;
            // TODO: TBD: #1 MWP 2020-07-01 11:58:07 AM: but which also beggars the question, should we be cleaning up after IDisposable members like messageBus?
            this._messageBus                    = messageBus;
            this._scenarioClass                 = scenarioClass;
            this._constructorArguments          = constructorArguments; // TODO: TBD: put fluent validation guards on the arguments?
            this._scenarioMethod                = scenarioMethod;
            this._scenarioMethodArguments       = scenarioMethodArguments;
            this._beforeAfterScenarioAttributes = beforeAfterScenarioAttributes;
            this._aggregator                    = aggregator;
            this._cancellationTokenSource       = cancellationTokenSource;
        }