Ejemplo n.º 1
0
        public void ProcessRuleReplacementsWithMatchTagsAndExactMatch()
        {
            // arrange
            var responseString = OutboundRewriterTestData.ProcessRuleReplacementsWithMatchTagsInput;
            var outboundRule   = new OutboundRule
            {
                Using = Using.ExactMatch,
                OutboundMatchScope = new MatchResponseTags()
                {
                    MatchTheContentWithin = new List <MatchTag>
                    {
                        new MatchTag {
                            Tag = "a", Attribute = "href"
                        }
                    }
                },
                Pattern = @"/article\.aspx\?id=([0-9]+)(?:&|&amp;)title=([_0-9a-z-]+)$",
                Action  = new OutboundRewrite()
                {
                    Value = @"/newarticle.aspx"
                },
                MatchingScopeType = ScopeType.Response
            };

            // act
            var output = OutboundRewriter.ProcessRuleReplacements(responseString, outboundRule);

            // assert
            Assert.AreEqual(output, OutboundRewriterTestData.ProcessRuleReplacementsWithMatchTagsAndExactMatchExpectedOutput);
        }
Ejemplo n.º 2
0
        public void ProcessRuleReplacementsWithNoMatchTags()
        {
            // arrange
            var responseString = OutboundRewriterTestData.ProcessRuleReplacementsWithMatchTagsInput;
            var outboundRule   = new OutboundRule
            {
                Pattern = @"/article\.aspx\?id=([0-9]+)(?:&|&amp;)title=([_0-9a-z-]+)",
                Action  = new OutboundRewrite()
                {
                    Value = @"/article/{R:1}/{R:2}"
                },
                MatchingScopeType = ScopeType.Response
            };

            // act
            var output = OutboundRewriter.ProcessRuleReplacements(responseString, outboundRule);

            // assert
            Assert.AreEqual(output, OutboundRewriterTestData.ProcessRuleReplacementsWithMatchTagsExpectedOutput);
        }
Ejemplo n.º 3
0
        public void ProcessRuleReplacementsWithExactMatch()
        {
            // arrange
            var responseString = OutboundRewriterTestData.ProcessRuleReplacementsWithMatchTagsInput;
            var outboundRule   = new OutboundRule
            {
                Using   = Using.ExactMatch,
                Pattern = @"</body>",
                Action  = new OutboundRewrite()
                {
                    Value = @"<script type='text/javascript'>//Your web analytics tracking code goes here...</script></body>"
                },
                MatchingScopeType = ScopeType.Response
            };

            // act
            var output = OutboundRewriter.ProcessRuleReplacements(responseString, outboundRule);

            // assert
            Assert.AreEqual(output, OutboundRewriterTestData.ProcessRuleReplacementsWithExactMatchExpectedOutput);
        }