Beispiel #1
0
 public Step(Step step)
 {
     Id             = step.Id;
     _title         = step._title;
     Asserts        = step.Asserts;
     ExecutionOrder = step.ExecutionOrder;
     ShouldReport   = step.ShouldReport;
     Result         = Result.NotExecuted;
     Action         = step.Action;
     Arguments      = step.Arguments;
 }
Beispiel #2
0
 public Step(Step step)
 {
     Id = step.Id;
     _title = step._title;
     Asserts = step.Asserts;
     ExecutionOrder = step.ExecutionOrder;
     ShouldReport = step.ShouldReport;
     Result = Result.NotExecuted;
     Action = step.Action;
     Arguments = step.Arguments;
 }
        public IEnumerable <Step> Scan(ITestContext testContext, MethodInfo candidateMethod)
        {
            var executableAttribute = (ExecutableAttribute)candidateMethod.GetCustomAttributes(typeof(ExecutableAttribute), true).FirstOrDefault();

            if (executableAttribute == null)
            {
                yield break;
            }

            var stepTitle = new StepTitle(executableAttribute.StepTitle);

            if (string.IsNullOrEmpty(stepTitle))
            {
                stepTitle = new StepTitle(Configurator.Scanners.Humanize(candidateMethod.Name));
            }

            var stepAsserts  = IsAssertingByAttribute(candidateMethod);
            var shouldReport = executableAttribute.ShouldReport;

            var runStepWithArgsAttributes = (RunStepWithArgsAttribute[])candidateMethod.GetCustomAttributes(typeof(RunStepWithArgsAttribute), true);

            if (runStepWithArgsAttributes.Length == 0)
            {
                var stepAction = StepActionFactory.GetStepAction(candidateMethod, new object[0]);
                yield return(new Step(stepAction, stepTitle, stepAsserts, executableAttribute.ExecutionOrder, shouldReport, new List <StepArgument>())
                {
                    ExecutionSubOrder = executableAttribute.Order
                });
            }

            foreach (var runStepWithArgsAttribute in runStepWithArgsAttributes)
            {
                var inputArguments   = runStepWithArgsAttribute.InputArguments;
                var flatInput        = inputArguments.FlattenArrays();
                var stringFlatInputs = flatInput.Select(i => i.ToString()).ToArray();
                var methodName       = stepTitle + " " + string.Join(", ", stringFlatInputs);

                if (!string.IsNullOrEmpty(runStepWithArgsAttribute.StepTextTemplate))
                {
                    methodName = string.Format(runStepWithArgsAttribute.StepTextTemplate, flatInput);
                }
                else if (!string.IsNullOrEmpty(executableAttribute.StepTitle))
                {
                    methodName = string.Format(executableAttribute.StepTitle, flatInput);
                }

                var stepAction = StepActionFactory.GetStepAction(candidateMethod, inputArguments);
                yield return(new Step(stepAction, new StepTitle(methodName), stepAsserts,
                                      executableAttribute.ExecutionOrder, shouldReport, new List <StepArgument>())
                {
                    ExecutionSubOrder = executableAttribute.Order
                });
            }
        }
Beispiel #4
0
        public void ResetTitle()
        {
            if (_stepAction != null)
            {
                var action         = _stepAction.Compile();
                var inputArguments = new StepArgument[0];
                if (_includeInputsInStepTitle)
                {
                    inputArguments = _stepAction.ExtractArguments(_testObject).ToArray();
                }

                _title = _createTitle(_stepTextTemplate, _includeInputsInStepTitle, _getMethodInfo(_stepAction), inputArguments, _stepPrefix);
            }
        }
Beispiel #5
0
 public Step(LambdaExpression stepAction, string stepTextTemplate, bool includeInputsInStepTitle, Func <LambdaExpression, MethodInfo> getMethodInfo, string stepPrefix, Func <string, bool, MethodInfo, StepArgument[], string, StepTitle> createTitle, Func <object, object> action, StepTitle title, bool assert, ExecutionOrder executionOrder, bool shouldReport, List <StepArgument> args)
 {
     _stepAction               = stepAction;
     _stepTextTemplate         = stepTextTemplate;
     _includeInputsInStepTitle = includeInputsInStepTitle;
     _getMethodInfo            = getMethodInfo;
     _stepPrefix               = stepPrefix;
     Action         = action;
     _title         = title;
     Asserts        = assert;
     ExecutionOrder = executionOrder;
     ShouldReport   = shouldReport;
     Arguments      = args;
     _createTitle   = createTitle;
 }
Beispiel #6
0
 public Step(
     Func <object, object> action,
     StepTitle title,
     bool asserts,
     ExecutionOrder executionOrder,
     bool shouldReport,
     List <StepArgument> arguments)
 {
     Id             = Configurator.IdGenerator.GetStepId();
     Asserts        = asserts;
     ExecutionOrder = executionOrder;
     ShouldReport   = shouldReport;
     Result         = Result.NotExecuted;
     Action         = action;
     Arguments      = arguments;
     _title         = title;
 }
Beispiel #7
0
 public Step(
     Action<object> action,
     StepTitle title,
     bool asserts,
     ExecutionOrder executionOrder,
     bool shouldReport, 
     List<StepArgument> arguments)
 {
     Id = Configurator.IdGenerator.GetStepId();
     Asserts = asserts;
     ExecutionOrder = executionOrder;
     ShouldReport = shouldReport;
     Result = Result.NotExecuted;
     Action = action;
     Arguments = arguments;
     _title = title;
 }
        public IEnumerable<Step> Scan(ITestContext testContext, MethodInfo candidateMethod)
        {
            var executableAttribute = (ExecutableAttribute)candidateMethod.GetCustomAttributes(typeof(ExecutableAttribute), true).FirstOrDefault();
            if(executableAttribute == null)
                yield break;

            var stepTitle = new StepTitle(executableAttribute.StepTitle);
            if(string.IsNullOrEmpty(stepTitle))
                stepTitle = new StepTitle(Configurator.Scanners.Humanize(candidateMethod.Name));

            var stepAsserts = IsAssertingByAttribute(candidateMethod);
            var shouldReport = executableAttribute.ShouldReport;

            var runStepWithArgsAttributes = (RunStepWithArgsAttribute[])candidateMethod.GetCustomAttributes(typeof(RunStepWithArgsAttribute), true);
            if (runStepWithArgsAttributes.Length == 0)
            {
                var stepAction = StepActionFactory.GetStepAction(candidateMethod, new object[0]);
                yield return new Step(stepAction, stepTitle, stepAsserts, executableAttribute.ExecutionOrder, shouldReport, new List<StepArgument>())
                        {
                            ExecutionSubOrder = executableAttribute.Order
                        };
            }

            foreach (var runStepWithArgsAttribute in runStepWithArgsAttributes)
            {
                var inputArguments = runStepWithArgsAttribute.InputArguments;
                var flatInput = inputArguments.FlattenArrays();
                var stringFlatInputs = flatInput.Select(i => i.ToString()).ToArray();
                var methodName = stepTitle + " " + string.Join(", ", stringFlatInputs);

                if (!string.IsNullOrEmpty(runStepWithArgsAttribute.StepTextTemplate))
                    methodName = string.Format(runStepWithArgsAttribute.StepTextTemplate, flatInput);
                else if (!string.IsNullOrEmpty(executableAttribute.StepTitle))
                    methodName = string.Format(executableAttribute.StepTitle, flatInput);

                var stepAction = StepActionFactory.GetStepAction(candidateMethod, inputArguments);
                yield return new Step(stepAction, new StepTitle(methodName), stepAsserts,
                                      executableAttribute.ExecutionOrder, shouldReport, new List<StepArgument>())
                        {
                            ExecutionSubOrder = executableAttribute.Order
                        };
            }
        }