예제 #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)));
        }
예제 #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);
        }
예제 #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);
        }
예제 #4
0
 private void AddSubstitutions()
 {
     HttpResponseSubstitutionHandler
     .Add(Substitutions.CurrentTime, Substitutions.CurrentTimeCallback);
 }