private void Init()
 {
     NBehaveInitializer.Initialize(ConfigurationNoAppDomain.New.SetEventListener(Framework.EventListeners.EventListeners.NullEventListener()));
     actionCatalog = TinyIoCContainer.Current.Resolve<ActionCatalog>();
     stringStepRunner = new StringStepRunner(actionCatalog);
     runner = new FeatureRunner(stringStepRunner, TinyIoCContainer.Current.Resolve<IRunContext>());
 }
Example #2
0
        public FeatureResults Run()
        {
            NBehaveInitializer.Initialize(configuration);
            actionCatalog = TinyIoCContainer.Current.Resolve <ActionCatalog>();
            var featureRunner = TinyIoCContainer.Current.Resolve <IFeatureRunner>();
            var context       = TinyIoCContainer.Current.Resolve <IRunContext>();
            var results       = new FeatureResults();

            try
            {
                context.RunStarted();
                LoadAssemblies();
                var loader   = new LoadScenarioFiles(configuration);
                var files    = loader.LoadFiles();
                var parse    = new ParseScenarioFiles(configuration);
                var features = parse.LoadFiles(files);
                results = Run(featureRunner, features, context);
            }
            finally
            {
                context.RunFinished(results);
            }

            return(results);
        }
 public ActionStepStepResolver(object stepHelper)
 {
     _stepHelper = stepHelper;
     _actionCatalog = new ActionCatalog();
     _stepParser = new ActionStepParser(new StoryRunnerFilter(), _actionCatalog);
     _stepParser.FindActionStepMethods(stepHelper.GetType(), _stepHelper);
     _parameterConverter = new ParameterConverter(_actionCatalog);
 }
Example #4
0
 private void CreateActionCatalog()
 {
     actionCatalog = new ActionCatalog();
     Action<string> given = x => { };
     actionCatalog.Add(new ActionMethodInfo("name $x".AsRegex(), given, given.Method, "Given"));
     Action when = () => { };
     actionCatalog.Add(new ActionMethodInfo("greeted".AsRegex(), when, when.Method, "When"));
     Action<string> then = y => Assert.AreEqual("Nisse", y);
     actionCatalog.Add(new ActionMethodInfo("Hello $y".AsRegex(), then, then.Method, "Then"));
 }
Example #5
0
            public void ShouldConsiderThe2ActionsAsEqual()
            {
                var catalog = new ActionCatalog();

                var action = new ActionMethodInfo(
                    "my savings account balance is $balance".AsRegex(),
                    new object(),
                    GetDummyParameterInfo(),
                    null);

                catalog.Add(action);
                var actionExists = catalog.ActionExists("Given my savings account balance is 500".AsStringStep(""));

                Assert.That(actionExists, Is.True);
            }
Example #6
0
            public void ShouldGetAction()
            {
                var catalog = new ActionCatalog();

                var action = new ActionMethodInfo(
                    "my savings account balance is $balance".AsRegex(),
                    new object(),
                    GetDummyParameterInfo(),
                    null);

                catalog.Add(action);

                var actionResult = catalog.GetAction(new StringStep("Given my savings account balance is 500", ""));

                Assert.That(actionResult, Is.Not.Null);
            }
Example #7
0
            public void ShouldGetActionWithTokenInMiddleOfString()
            {
                var catalog = new ActionCatalog();
                Action<int> action = accountBalance => { };

                var actionMethodInfo = new ActionMethodInfo(
                    "I have $amount euros on my cash account".AsRegex(),
                    action,
                    action.Method,
                    null);

                catalog.Add(actionMethodInfo);

                var actionFetched = catalog.GetAction(new StringStep("Given I have 20 euros on my cash account", ""));

                Assert.That(actionFetched, Is.Not.Null);
            }
Example #8
0
 public void Run(StringStep step)
 {
     try
     {
         if (!ActionCatalog.ActionExists(step))
         {
             var pendReason = string.Format("No matching Action found for \"{0}\"", step);
             step.PendNotImplemented(pendReason);
         }
         else
         {
             RunStep(step);
         }
     }
     catch (Exception e)
     {
         var realException = FindUsefulException(e);
         step.Fail(realException);
     }
 }
Example #9
0
        public FeatureResults Run()
        {
            NBehaveInitializer.Initialize(configuration);
            actionCatalog = TinyIoCContainer.Current.Resolve<ActionCatalog>();
            var featureRunner = TinyIoCContainer.Current.Resolve<IFeatureRunner>();
            var context = TinyIoCContainer.Current.Resolve<IRunContext>();
            var results = new FeatureResults();
            try
            {
                context.RunStarted();
                LoadAssemblies();
                var loader = new LoadScenarioFiles(configuration);
                var files = loader.LoadFiles();
                var parse = new ParseScenarioFiles(configuration);
                var features = parse.LoadFiles(files);
                results = Run(featureRunner, features, context);
            }
            finally
            {
                context.RunFinished(results);
            }

            return results;
        }
Example #10
0
        private void RunStep(StringStep actionStep)
        {
            var info = ActionCatalog.GetAction(actionStep);

            try
            {
                //TODO: Move Before-/After-EachStep to RunContext !!
                BeforeEachScenario(info);
                BeforeEachStep(info);
                if (actionStep is StringTableStep && !ShouldForEachOverStep(info))
                {
                    ForEachOverStep(actionStep as StringTableStep, info);
                }
                else
                {
                    RunStep(info, () => ParameterConverter.GetParametersForStep(actionStep));
                }
            }
            finally
            {
                lastAction = info;
                AfterEachStep(info);
            }
        }
Example #11
0
 public StringStepRunner(ActionCatalog actionCatalog)
 {
     ActionCatalog      = actionCatalog;
     ParameterConverter = new ParameterConverter(ActionCatalog);
 }
Example #12
0
 public ParameterConverter(ActionCatalog actionCatalog)
 {
     _actionCatalog = actionCatalog;
 }
Example #13
0
 public virtual void Setup()
 {
     actionCatalog = new ActionCatalog();
     runner = new StringStepRunner(actionCatalog);
 }
Example #14
0
 public ParameterConverter(ActionCatalog actionCatalog)
 {
     _actionCatalog = actionCatalog;
 }
Example #15
0
 public StringStepRunner(ActionCatalog actionCatalog)
 {
     ActionCatalog = actionCatalog;
     ParameterConverter = new ParameterConverter(ActionCatalog);
 }
Example #16
0
 public ActionStepParser(StoryRunnerFilter storyRunnerFilter, ActionCatalog actionCatalog)
 {
     this.storyRunnerFilter    = storyRunnerFilter;
     this.actionCatalog        = actionCatalog;
     methodWithAttributeFinder = new MethodWithAttributeFinder(storyRunnerFilter);
 }
Example #17
0
            public void EstablishContext()
            {
                _wasCalled = false;
                _actionCatalog = new ActionCatalog();
                Action firstAction = () => Assert.Fail("This action shouldnt be called");
                var actionMethod = new ActionMethodInfo(new Regex("def$"), firstAction, firstAction.Method, "Given", this);
                _actionCatalog.Add(actionMethod);

                Action secondAction = () => { _wasCalled = true; };
                var secondActionMethod = new ActionMethodInfo(new Regex("abc def$"), secondAction, secondAction.Method, "Given", this);
                _actionCatalog.Add(secondActionMethod);
            }
Example #18
0
            public void EstablishContext()
            {
                _actionCatalog = new ActionCatalog();
                Action<string, string> firstAction = (a, b) => { };
                var stepMatcher = "$a and $b".AsRegex();
                var actionMethod = new ActionMethodInfo(stepMatcher, firstAction, firstAction.Method, "Given", this);
                _actionCatalog.Add(actionMethod);

                Action<FooBar> secondAction = _ => { };
                var secondActionMethod = new ActionMethodInfo(stepMatcher, secondAction, secondAction.Method, "Given", this);
                _actionCatalog.Add(secondActionMethod);

                Action<List<FooBar>> thirdAction = _ => { };
                var thirdActionMethod = new ActionMethodInfo(stepMatcher, thirdAction, thirdAction.Method, "Given", this);
                _actionCatalog.Add(thirdActionMethod);
            }
Example #19
0
 public ActionStepParser(StoryRunnerFilter storyRunnerFilter, ActionCatalog actionCatalog)
 {
     this.storyRunnerFilter = storyRunnerFilter;
     this.actionCatalog = actionCatalog;
     methodWithAttributeFinder = new MethodWithAttributeFinder(storyRunnerFilter);
 }
Example #20
0
 public virtual void SetUp()
 {
     _actionCatalog = new ActionCatalog();
     _actionStepParser = new ActionStepParser(_storyRunnerFilter, _actionCatalog);
     _actionStepParser.FindActionSteps(GetType().Assembly);
 }