public void GetRouteData_IfHttpRouteGetRouteDataThrows_RoutesToExceptionHandler() { // Arrange Exception expectedException = CreateException(); IHttpRoute route = CreateThrowingRoute(expectedException); HttpWebRoute product = CreateProductUnderTest(route); HttpRequestBase requestBase = CreateStubRequestBase("GET"); HttpContextBase contextBase = CreateStubContextBase(requestBase); using (HttpRequestMessage request = CreateRequest()) { contextBase.SetHttpRequestMessage(request); // Act RouteData routeData = product.GetRouteData(contextBase); // Assert Assert.NotNull(routeData); Assert.Same(product, routeData.Route); HttpRouteExceptionRouteHandler typedHandler = Assert.IsType <HttpRouteExceptionRouteHandler>(routeData.RouteHandler); ExceptionDispatchInfo exceptionInfo = typedHandler.ExceptionInfo; Assert.NotNull(exceptionInfo); // Guard Assert.Same(expectedException, exceptionInfo.SourceException); } }
public void ExceptionInfo_ReturnsSpecifiedInstance() { // Arrange ExceptionDispatchInfo expectedExceptionInfo = CreateExceptionInfo(); HttpRouteExceptionRouteHandler product = CreateProductUnderTest(expectedExceptionInfo); // Act ExceptionDispatchInfo exceptionInfo = product.ExceptionInfo; // Assert Assert.Same(exceptionInfo, expectedExceptionInfo); }