public async Task InitializeAsync()
        {
            var bugsnag = new Bugsnag.Tests.TestServer();

            bugsnag.Start();

            var builder = new WebHostBuilder()
                          .ConfigureServices(services => services.AddBugsnag(config => { config.ApiKey = "123456"; config.Endpoint = bugsnag.Endpoint; }))
                          .Configure(app => {
                app.UseExceptionHandler("/home");
                app.Map("/error", error => {
                    error.Run(handler => {
                        throw new System.Exception("a serious error");
                    });
                });
                app.Map("/home", home => {
                    home.Run(async handler => {
                        await handler.Response.WriteAsync("OK");
                    });
                });
            });

            var server   = new TestServer(builder);
            var client   = server.CreateClient();
            var response = await client.SendAsync(new System.Net.Http.HttpRequestMessage()
            {
                RequestUri = new Uri("/error", UriKind.Relative)
            });

            var bugsnags = await bugsnag.Requests(1);

            BugsnagPayload = bugsnags.First();
        }
Пример #2
0
        public async void TestWithDeveloperExceptionPage()
        {
            var bugsnag = new Bugsnag.Tests.TestServer();

            bugsnag.Start();

            var builder = new WebHostBuilder()
                          .ConfigureServices(services => services.AddBugsnag(config => { config.ApiKey = "123456"; config.Endpoint = bugsnag.Endpoint; }))
                          .Configure(app => {
                app.UseDeveloperExceptionPage();
                app.Run(context => {
                    throw new System.Exception("a serious error");
                });
            });

            var server   = new TestServer(builder);
            var client   = server.CreateClient();
            var response = await client.SendAsync(new System.Net.Http.HttpRequestMessage());

            var bugsnags = await bugsnag.Requests(1);

            Assert.NotNull(response);
        }