Exemplo n.º 1
0
 public static void Add(string name, ParameterizedHttpResponseSubstitutionCallback callback)
 {
     g_callbacks.Add(
         new Pair <string, ParameterizedHttpResponseSubstitutionCallback>(
             g_prefix + name, callback));
     g_callbackMap.Add(g_prefix + name, callback);
 }
Exemplo n.º 2
0
        public void GetHttpHandler_StartEndCallbacks()
        {
            // Arrange
            m_mockContext.Setup(c => c.Request.HttpMethod).Returns("GET");
            var requestContext = new RequestContext(m_mockContext.Object, new RouteData());
            ParameterizedHttpResponseSubstitutionCallback startCallback = (c, s) => string.Empty;
            ParameterizedHttpResponseSubstitutionCallback endCallback   = (c, s) => string.Empty;
            var handler = new HttpResponseSubstitutionRouteHandler()
            {
                StartCallback = startCallback,
                EndCallback   = endCallback
            };

            // Act
            var result = handler.GetHttpHandler(requestContext);

            // Assert
            Assert.NotNull(result);
            Assert.IsType <HttpResponseSubstitutionHandler>(result);
            var httpHandler = (HttpResponseSubstitutionHandler)result;

            Assert.Same(startCallback, httpHandler.StartCallback);
            Assert.Same(endCallback, httpHandler.EndCallback);
        }
Exemplo n.º 3
0
 private void AddSubstitution(HttpResponse response, ParameterizedHttpResponseSubstitutionCallback callback)
 {
     response.WriteSubstitution(c => callback(new HttpContextWrapper(c), State));
 }