Exemplo n.º 1
0
        public static MvcHtmlString RenderSubstitution(this HtmlHelper helper, string name, object state)
        {
            var context = helper.ViewContext.HttpContext;

            return(MvcHtmlString.Create(
                       context.Handler is HttpResponseSubstitutionHandler
                ? HttpResponseSubstitutionHandler.Token(name)
                : HttpResponseSubstitutionHandler.Execute(context, name, state)));
        }
Exemplo n.º 2
0
        public void RenderSubstitution_Token()
        {
            // Arrange
            m_mockContext.Setup(c => c.Handler).Returns(new HttpResponseSubstitutionHandler(null));

            // Act
            var result = SubstitutionHelper.RenderSubstitution(m_htmlHelper, "name").ToHtmlString();

            // Assert
            Assert.Equal(HttpResponseSubstitutionHandler.Token("name"), result);
        }
Exemplo n.º 3
0
        public SubstitutionHelperTest()
        {
            if (!g_substitutionAdded)
            {
                HttpResponseSubstitutionHandler.Add("name", (c, s) => "result");
                g_substitutionAdded = true;
            }

            m_mockContext = MockHttpFactory.GetHttpContext();
            m_htmlHelper  = MockHttpFactory.GetHtmlHelper(m_mockContext.Object);
        }
Exemplo n.º 4
0
 private void AddSubstitutions()
 {
     HttpResponseSubstitutionHandler
     .Add(Substitutions.CurrentTime, Substitutions.CurrentTimeCallback);
 }