public void Send_EndRequestEventIsInvoked_And_ResponseOnlyContainsApiError() { bool requestEndInvoked = false; AirbrakeResponseError[] errors = null; int i = 0; this.client.RequestEnd += (sender, e) => { requestEndInvoked = true; errors = e.Response.Errors; }; var configuration = new AirbrakeConfiguration { ApiKey = Guid.NewGuid().ToString("N"), EnvironmentName = "test", }; var builder = new AirbrakeNoticeBuilder(configuration); AirbrakeNotice notice = builder.Notice(new Exception("Test")); notice.Request = new AirbrakeRequest("http://example.com", "Test") { Params = new[] { new AirbrakeVar("TestKey", "TestValue") } }; this.client.Send(notice); while (!requestEndInvoked) { // Sleep for maximum 5 seconds to wait for the request to end. Can probably be done more elegantly. if (i++ == 50) { break; } Thread.Sleep(100); } Assert.That(requestEndInvoked, Is.True); Assert.That(errors, Is.Not.Null); Assert.That(errors, Has.Length.EqualTo(1)); }
public void Send_EndRequestEventIsInvoked_And_ResponseOnlyContainsApiError() { bool requestEndInvoked = false; AirbrakeResponseError[] errors = null; int i = 0; this.client.RequestEnd += (sender, e) => { requestEndInvoked = true; errors = e.Response.Errors; }; var configuration = new AirbrakeConfiguration { ApiKey = Guid.NewGuid().ToString("N"), EnvironmentName = "test", }; var builder = new AirbrakeNoticeBuilder(configuration); AirbrakeNotice notice = builder.Notice(new Exception("Test")); notice.Request = new AirbrakeRequest("http://example.com", "Test") { Params = new[] { new AirbrakeVar("TestKey", "TestValue") } }; this.client.Send(notice); while (!requestEndInvoked) { // Sleep for maximum 5 seconds to wait for the request to end. Can probably be done more elegantly. if (i++ == 50) break; Thread.Sleep(100); } Assert.That(requestEndInvoked, Is.True); Assert.That(errors, Is.Not.Null); Assert.That(errors, Has.Length.EqualTo(1)); }
public void Send_EndRequestEventIsInvoked_And_ResponseOnlyContainsApiError() { bool requestEndInvoked = false; AirbrakeResponseError[] errors = null; int i = 0; this.client.RequestEnd += (sender, e) => { requestEndInvoked = true; errors = e.Response.Errors; }; var configuration = new AirbrakeConfiguration { ApiKey = Guid.NewGuid().ToString("N"), EnvironmentName = "test", }; var builder = new AirbrakeNoticeBuilder(configuration); AirbrakeNotice notice = builder.Notice(new Exception("Test")); notice.Request = new AirbrakeRequest("http://example.com", "Test") { Params = new[] { new AirbrakeVar("TestKey", "TestValue") } }; this.client.Send(notice); Assert.That(requestEndInvoked, Is.True.After(5000)); Assert.That(errors, Is.Not.Null); Assert.That(errors, Has.Length.EqualTo(1)); }
public void SendEndRequestEventIsInvokedAndResponseOnlyContainsApiError() { bool requestEndInvoked = false; IList<AirbrakeResponseError> errors = null; _client.RequestEnd += (sender, e) => { requestEndInvoked = true; errors = e.Response.Errors; }; var configuration = new AirbrakeConfiguration { ApiKey = Guid.NewGuid().ToString("N"), EnvironmentName = "test", }; var builder = new AirbrakeNoticeBuilder(configuration); AirbrakeNotice notice = builder.BuildNotice(new Exception("Test")); notice.Request = new AirbrakeRequest("http://example.com", "Test") { Params = new[] { new AirbrakeVar("TestKey", "TestValue") } }; _client.Send(notice); Assert.That(requestEndInvoked, Is.True.After(5000)); Assert.That(errors, Is.Not.Null); Assert.That(errors, Has.Length.EqualTo(1)); }
public SharpbrakeClient(AirbrakeClient client, AirbrakeNoticeBuilder builder) { this.Client = new AirbrakeClient(); this.Builder = new AirbrakeNoticeBuilder(); }
public void SetUp() { this.config = new AirbrakeConfiguration { ApiKey = "123456", EnvironmentName = "test" }; this.builder = new AirbrakeNoticeBuilder(this.config); }