public void SetUp()
 {
     _config = new AirbrakeConfiguration
     {
         ApiKey = "123456",
         EnvironmentName = "test"
     };
     _builder = new AirbrakeNoticeBuilder(_config);
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AirbrakeClient"/> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="builder">Optional: A different builder.</param>
        public AirbrakeClient(IAirbrakeConfiguration configuration, IAirbrakeNoticeBuilder builder = null)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");

            if (builder == null)
                builder = new AirbrakeNoticeBuilder(configuration);

            _configuration = configuration;
            _builder = builder;
            _log = LogManager.GetLogger(GetType());
        }
Esempio n. 3
0
        public void Send_EndRequestEventIsInvoked_And_ResponseOnlyContainsApiError()
        {
            var requestEndInvoked = false;
            AirbrakeResponseError[] errors = null;

            _client.RequestEnd += (sender, e) =>
            {
                requestEndInvoked = true;
                errors = e.Response.Errors;
            };

            var configuration = new AirbrakeConfiguration
            {
                ApiKey = Guid.NewGuid().ToString("N"),
                EnvironmentName = "test",
                ProjectRoot = Environment.CurrentDirectory
            };

            var builder = new AirbrakeNoticeBuilder(configuration);

            var notice = builder.Notice(Util.SimulateException());

            notice.Request = new AirbrakeRequest("http://example.com", "Test", "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));
        }