public void when_connecting_to_exceptional() { var client = new ExceptionalClient(ApiKey()); var request = new HttpRequestSummary { Action = "Test", Url = "http://localhost/test", RequestMethod = "GET", Controller = "TestController", RemoteIp = "192.168.255.1", Headers = new Dictionary<string, string> { {"Version", "HTTP/1.1"}, {"User-Agent", "Test"}, }, Parameters = new Dictionary<string, string> { {"Action", "Test"}, {"Controller", "TestController"} }, Session = new Dictionary<string, string> { {"UserID", "123"}, {"demo:Person", "99883"} } }; var alert = new Alert(CreateException()); alert.Request = request; it["should report"] = () => client.Send(alert); }
public static HttpRequestSummary CreateHttpRequestSummary(ExceptionContext context) { var summary = new HttpRequestSummary(); var session = context.HttpContext.Session; var headers = context.HttpContext.Request.Headers; summary.Action = context.RouteData.Values["action"] as string; summary.Controller = context.RouteData.Values["controller"] as string; summary.Headers = headers.AllKeys.ToDictionary(k => k, k => headers[k]); summary.Parameters = context.RouteData.Values.Union(context.RouteData.DataTokens).ToDictionary(k => k.Key, v => Serializer.SanitizeItem(v.Value)); summary.RemoteIp = context.HttpContext.Request.UserHostAddress; summary.RequestMethod = context.HttpContext.Request.HttpMethod; if (session != null) summary.Session = session.Keys.Cast<string>().ToDictionary(k => k, k => Serializer.SanitizeItem(session[k])); summary.Url = GenerateUrl(context.HttpContext.Request); return summary; }