public void GetHttpHandler_Returns_MvcHandler() { // Arrange m_mockContext.Setup(c => c.Request.HttpMethod).Returns("POST"); var requestContext = new RequestContext(m_mockContext.Object, new RouteData()); var handler = new HttpResponseSubstitutionRouteHandler(); // Act var result = handler.GetHttpHandler(requestContext); // Assert Assert.NotNull(result); Assert.IsType <MvcHandler>(result); }
private void AddRouting() { var handler = new HttpResponseSubstitutionRouteHandler() { StateProvider = SubstitutionStateProvider.RouteValues, StartCallback = Substitutions.StartCallback }; var routes = RouteTable.Routes; routes.MapRoute("cache-substitution", "{language}/cache-substitution", new { controller = "Home", action = "CacheSubstitution", id = string.Empty, language = Localization.DefaultLanguage, }, handler); }
public void GetHttpHandler_AquireState() { // Arrange m_mockContext.Setup(c => c.Request.HttpMethod).Returns("GET"); var requestContext = new RequestContext(m_mockContext.Object, new RouteData()); var handler = new HttpResponseSubstitutionRouteHandler() { StateProvider = x => { Assert.Same(requestContext, x); return("x"); } }; // Act var result = handler.GetHttpHandler(requestContext); // Assert Assert.NotNull(result); Assert.IsType <HttpResponseSubstitutionHandler>(result); Assert.Equal("x", ((HttpResponseSubstitutionHandler)result).State); }
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); }