public void ShouldBuildInstanceWithGivenActions()
 {
     var action1 = new StubElementTransformerAction();
     var action2 = new StubElementTransformerAction();
     GivenATarget();
     GivenAction(action1);
     GivenAction(action2);
     WhenBuilt();
     ResultShouldHaveActions(action1, action2);
 }
        public void ShouldReturnAnElementTransformerContainingAllMatchesForCurrentNode()
        {
            Tag tag = new Tag("fred");
            var transformerAction  = new StubElementTransformerAction();
            var transformerAction2 = new StubElementTransformerAction();

            GivenAnElementTarget(tag);
            GivenASpecification(tag, transformerAction, transformerAction2);
            WhenAnElementTransformerIsRequested();
            ThenTheElementTransformerShouldContainOnly(transformerAction, transformerAction2);
        }
        public void ShouldReturnAnElementTransformerContainingAllMatchesForCurrentNode()
        {
            Tag tag = new Tag("fred");
            var transformerAction = new StubElementTransformerAction();
            var transformerAction2 = new StubElementTransformerAction();

            GivenAnElementTarget(tag);
            GivenASpecification(tag, transformerAction, transformerAction2);
            WhenAnElementTransformerIsRequested();
            ThenTheElementTransformerShouldContainOnly(transformerAction, transformerAction2);
        }
        public void ShouldReturnAnElementTransformerContainingAllMatchesForCurrentNode()
        {
            TestElement element = InternalTestNodes.TestElement("fred");
            var transformerAction = new StubElementTransformerAction();
            var transformerAction2 = new StubElementTransformerAction();

            GivenAnElementTarget(element);
            GivenASpecification(element, transformerAction, transformerAction2);
            WhenAnElementTransformerIsRequested();
            ThenTheElementTransformerShouldContainOnly(transformerAction, transformerAction2);
        }
        public void ShouldReturnActionsWhenMoreThanOneNodeMatch()
        {
            Tag currentTag = new Tag("currentTag");
            var applicableAction1 = new StubElementTransformerAction();
            var applicableAction2 = new StubElementTransformerAction();

            GivenATagAndAction(currentTag, applicableAction1);
            GivenATagAndAction(currentTag, applicableAction2);
            WhenActionsRequestedFor(currentTag);
            ReturnedActionsShouldbe(applicableAction1, applicableAction2);
        }
        public void ShouldReturnActionsWhenOnlyOneNodeMatch()
        {
            const string currentElementName = "currentElement";
            TestElement element = InternalTestNodes.TestElement(currentElementName);
            var applicableAction1 = new StubElementTransformerAction();
            var applicableAction2 = new StubElementTransformerAction();

            GivenAMatcherAndAction(new NodeMatcher(currentElementName), applicableAction1, applicableAction2);
            GivenAMatcherAndAction(new NodeMatcher("anotherElement"), new StubElementTransformerAction(), new StubElementTransformerAction());
            WhenActionsRequestedFor(element);
            ReturnedActionsShouldbe(applicableAction1, applicableAction2);
        }
 public void ResultShouldNotHaveSameReferenceAsOriginal()
 {
     var action1 = new StubElementTransformerAction();
     var action2 = new StubElementTransformerAction();
     var action3 = new StubElementTransformerAction();
     GivenATarget();
     GivenAction(action1);
     GivenAction(action2);
     GivenAFinalAction(action3);
     WhenBuilt();
     ResultShouldNotBeReferenceEqualToTheOriginal();
 }
        public void ShouldReturnActionsWhenOnlyOneTagMatch()
        {
            Tag currentTag = new Tag("current");
            Tag anotherTag = new Tag("foobar123");
            var applicableAction1 = new StubElementTransformerAction();
            var applicableAction2 = new StubElementTransformerAction();

            GivenATagAndAction(currentTag, applicableAction1, applicableAction2);
            GivenATagAndAction(anotherTag, new StubElementTransformerAction(), new StubElementTransformerAction());
            WhenActionsRequestedFor(currentTag);
            ReturnedActionsShouldbe(applicableAction1, applicableAction2);
        }
        public void ShouldPlaceFinalElementTransformtionsAtEndOfList()
        {
            Tag tag = new Tag("fred");
            var transformerAction  = new StubElementTransformerAction();
            var transformerAction2 = new StubElementTransformerAction();
            var finalAction1       = new StubElementTransformerAction();
            var finalAction2       = new StubElementTransformerAction();

            GivenAnElementTarget(tag);
            GivenASpecification(tag, transformerAction, transformerAction2);
            WhenAnElementTransformerIsRequested();
            ThenTheElementTransformerShouldContainOnly(transformerAction, transformerAction2, finalAction1, finalAction2);
        }
        public void ShouldPlaceFinalElementTransformtionsAtEndOfList()
        {
            Tag tag = new Tag("fred");
            var transformerAction = new StubElementTransformerAction();
            var transformerAction2 = new StubElementTransformerAction();
            var finalAction1 = new StubElementTransformerAction();
            var finalAction2 = new StubElementTransformerAction();

            GivenAnElementTarget(tag);
            GivenASpecification(tag, transformerAction, transformerAction2);
            WhenAnElementTransformerIsRequested();
            ThenTheElementTransformerShouldContainOnly(transformerAction, transformerAction2, finalAction1, finalAction2);
        }
        public void ShouldPlaceFinalElementTransformtionsAtEndOfList()
        {
            Tag currentTag = new Tag("currentTag");
            var applicableAction1 = new StubElementTransformerAction();
            var applicableAction2 = new StubElementTransformerAction();
            var finalAction1 = new StubElementTransformerAction();
            var finalAction2 = new StubElementTransformerAction();

            GivenATagActionAndFinal(currentTag, new[] { applicableAction1 }, new[] { finalAction1 });
            GivenATagActionAndFinal(currentTag, new[] { applicableAction2 }, new[] { finalAction2 });
            WhenActionsRequestedFor(currentTag);
            ReturnedActionsShouldbe(applicableAction1, applicableAction2, finalAction1, finalAction2);
        }
 private void GivenAnElementAction(StubElementTransformerAction elementTransformerAction)
 {
     Context.Target.AddAction(elementTransformerAction);
 }