public void ExceptionContextWrapper() { var uri = "http://google.com/"; var mockRequest = new Mock <HttpRequestBase>(); mockRequest.Setup(r => r.HttpMethod).Returns("POST"); mockRequest.Setup(r => r.Url).Returns(new Uri(uri)); mockRequest.Setup(r => r.UserAgent).Returns("user-agent"); var mockResponse = new Mock <HttpResponseBase>(); var mockContext = new Mock <HttpContextBase>(); mockContext.Setup(c => c.Request).Returns(mockRequest.Object); mockContext.Setup(c => c.Response).Returns(mockResponse.Object); var context = new ExceptionContext { HttpContext = mockContext.Object, Exception = new Exception() }; var wrapper = new ExceptionContextWrapper(context); Assert.Equal("POST", wrapper.GetHttpMethod()); Assert.Equal(uri, wrapper.GetUri()); Assert.Equal("user-agent", wrapper.GetUserAgent()); }
public void ExceptionContextWrapper_Simple() { var mockContext = new Mock <HttpContextBase>(); mockContext.Setup(c => c.Request).Returns((HttpRequestBase)null); mockContext.Setup(c => c.Response).Returns((HttpResponseBase)null); var context = new ExceptionContext { HttpContext = mockContext.Object, Exception = new Exception() }; var wrapper = new ExceptionContextWrapper(context); Assert.Null(wrapper.GetHttpMethod()); Assert.Null(wrapper.GetUri()); Assert.Null(wrapper.GetUserAgent()); }