public void when_creating_exceptional_client()
        {
            context["static properties"] = () =>
                {
                    it["protocol version should be 6"] = () => ExceptionalClient.ProtocolVersion.should_be("6");
                    it["endpoint format should be set"] = () => ExceptionalClient.EndpointUrlFormat.should_be("http://api.exceptional.io/api/errors?api_key={0}&protocol_version={1}");
                };

            ExceptionalClient client = null;

            context["with api key"] = () =>
                {
                    const string apiKey = "1234567890";

                    before = () => client = new ExceptionalClient(apiKey);

                    it["ApiKey property should match"] = () => client.ApiKey.should_be(apiKey);
                    it["should generate endpoint URL containing API key and protocol version"] = () =>
                        client.GetEndpointUrl().should_be("http://api.exceptional.io/api/errors?api_key=" + apiKey +
                                                          "&protocol_version=" + ExceptionalClient.ProtocolVersion);
                    it["should pass validation"] = () => client.Validate();
                };

            context["with null api key"] = () =>
                {
                    before = () => client = new ExceptionalClient(null);

                    it["should not validate"] = () => expect<ExceptionalValidationException>(() => client.Validate());
                    it["should refuse to send"] = () => expect<ExceptionalValidationException>(() => client.Send(null));
                };
        }
 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);
 }
Пример #3
0
 public Exceptional(ExceptionalClient client)
 {
     Client = client;
 }