Inheritance: RegexMatchOperator
        public void GetMatches_Should_Be_Able_To_Feed_Into_Multiple_Transforms()
        {
            var stepDefinition = new StepDefinition {
                Regex = new Regex("^((?:[Uu]ser )?\"(?:[^\"]*)\"|the (?:most|least) senior user) is logged in$"),
                Action = new Action<int>(x => { })
            };
            var stepDefinitions = new List<StepDefinition> { stepDefinition };

            var transformDefinition1 = new TransformDefinition {
                Regex = new Regex("^(?:[Uu]ser )?\"([^\"]*)\"$"),
                Action = new Func<string, string>(s => s)
            };
            var transformDefinition2 = new TransformDefinition {
                Regex = new Regex("^the (most|least) senior user$"),
                Action = new Func<string, string>(s => s)
            };
            var transformDefinitions = new Dictionary<Type, IList<TransformDefinition>> { { typeof(int), new List<TransformDefinition> { transformDefinition1, transformDefinition2 } } };

            var stepSet = new Mock<IStepSet>();
            stepSet.Setup(ss => ss.StepDefinitions).Returns(stepDefinitions);
            stepSet.Setup(ss => ss.TransformDefinitions).Returns(transformDefinitions);

            stepMother.StepSets = new List<IStepSet> { stepSet.Object };
            stepMother.BuildStepCollection();

            var step = "the most senior user is logged in";
            stepMother.GetMatches(step);
        }
        public void GetMatches_Should_Return_NoMatch_For_Ambiguous_Transform()
        {
            var stepDefinition = new StepDefinition {
                Regex = new Regex("^I print the integer (\\d*)$"),
                Action = new Action<int>(Console.WriteLine)
            };
            var stepDefinitions = new List<StepDefinition> { stepDefinition };

            var transformDefinition1 = new TransformDefinition {
                Regex = new Regex("^(\\d)$"),
                Action = new Func<string, int>(int.Parse)
            };
            var transformDefinition2 = new TransformDefinition {
                Regex = new Regex("^(\\d+)$"),
                Action = new Func<string, int>(x => int.Parse(x) + 1)
            };
            var transformDefinitions = new Dictionary<Type, IList<TransformDefinition>> { { typeof(int), new List<TransformDefinition> { transformDefinition1, transformDefinition2 } } };

            var stepSet = new Mock<IStepSet>();
            stepSet.Setup(ss => ss.StepDefinitions).Returns(stepDefinitions);
            stepSet.Setup(ss => ss.TransformDefinitions).Returns(transformDefinitions);

            stepMother.StepSets = new List<IStepSet> { stepSet.Object };
            stepMother.BuildStepCollection();

            var step = "I print the integer 5";
            stepMother.GetMatches(step).Should().Be.Empty();
        }
 public void SetUp()
 {
     stepMother = new StepMother<EmptyWorldView>();
     transformDefinition1 = new TransformDefinition { Regex = new Regex("1"), Action = new Func<int>(() => 1) };
     transformDefinition2 = new TransformDefinition { Regex = new Regex("2"), Action = new Func<int>(() => 2) };
 }
        public void GetMatches_Should_Process_Unambiguous_Transform()
        {
            var stepDefinition = new StepDefinition {
                Regex = new Regex("^I print the integer (\\d*)$"),
                Action = new Action<int>(Console.WriteLine)
            };
            var stepDefinitions = new List<StepDefinition> { stepDefinition };

            var transformDefinition = new TransformDefinition {
                Regex = new Regex("^(\\d*)$"),
                Action = new Func<string, int>(int.Parse)
            };
            var transformDefinitions = new Dictionary<Type, IList<TransformDefinition>> { { typeof(int), new List<TransformDefinition> { transformDefinition } } };

            var stepSet = new Mock<IStepSet>();
            stepSet.Setup(ss => ss.StepDefinitions).Returns(stepDefinitions);
            stepSet.Setup(ss => ss.TransformDefinitions).Returns(transformDefinitions);

            stepMother.StepSets = new List<IStepSet> { stepSet.Object };
            stepMother.BuildStepCollection();

            var step = "I print the integer 5";
            var match = stepMother.GetMatches(step).Single();

            (match.StepDefinition).Should().Be.EqualTo(stepDefinition);
            (match.MatchedArguments).Should().Have.SameSequenceAs(new[] { new MatchedArgument { Text = "5", Value = 5, Position = 20 } });
        }