public void Matches_CallsMatchesOnFirstDefinitionStep()
        {
            var definitionStep = new StepDefinitionMock(PathMatch.Succeed(0));
            var definition     = PathDefinition.Empty.Append(definitionStep);

            definition.Matches(Path.Empty);

            Assert.AreEqual(
                1,
                definitionStep.InvocationCount,
                "The PathDefinition did not call the first PathDefinitionStep."
                );
        }
Пример #2
0
            private static PathDefinitionStep CreateStepStub(bool success, int matchLength = 0)
            {
                var mock = new Mock <PathDefinitionStep>();

                var result = success ?
                             PathMatch.Succeed(matchLength) :
                             PathMatch.Fail(matchLength);

                mock
                .Setup(x => x.Matches(It.IsAny <PathDefinitionIterator>(), It.IsAny <PathIterator>()))
                .Returns(result);

                return(mock.Object);
            }
        public void Matches_CallingMatchesNextOnPassedIteratorCallsNext()
        {
            var firstDefinitionStep  = new StepDefinitionMock(PathMatch.Succeed(0));
            var secondDefinitionStep = new StepDefinitionMock(PathMatch.Succeed(0));

            var definition = PathDefinition.Empty
                             .Append(firstDefinitionStep)
                             .Append(secondDefinitionStep);

            definition.Matches(Path.Empty);
            Assert.AreEqual(0, secondDefinitionStep.InvocationCount);

            firstDefinitionStep.DefinitionIterator.MatchesNext(Path.Empty.GetIterator());
            Assert.AreEqual(1, secondDefinitionStep.InvocationCount);
        }
        public void Matches_PassesPathIteratorAtFirstElementToFirstDefinitionStep()
        {
            var firstPathStep = new ViewModelStub();
            var path          = Path.Empty.Append(firstPathStep);

            var definitionStep = new StepDefinitionMock(PathMatch.Succeed(0));
            var definition     = PathDefinition.Empty.Append(definitionStep);

            definition.Matches(path);

            Assert.AreEqual(
                firstPathStep,
                definitionStep.PathIterator.ViewModel,
                "The PathIterator was not positioned at the first step."
                );
        }