Beispiel #1
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"));
        }
Beispiel #2
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);
            }
Beispiel #3
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);
            }
Beispiel #4
0
            public void ShouldConsiderAllWhitespaceAsEqual()
            {
                var catalog = new ActionCatalog();

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

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

                Assert.That(actionExists, Is.True);
            }
Beispiel #5
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);
            }
Beispiel #6
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);
            }