Ejemplo n.º 1
0
        public async Task Logs_UnhandledException()
        {
            await Assert.ThrowsAsync <Exception>(()
                                                 => _client.GetAsync($"/ErrorLoggingSamples/{nameof(ErrorLoggingSamplesController.ThrowsException)}/{_testId}"));

            var errorEvent = s_polling.GetEvents(_testId, 1).Single();

            ErrorEventEntryVerifiers.VerifyFullErrorEventLogged(errorEvent, _testId, nameof(ErrorLoggingSamplesController.ThrowsException));
        }
        private static async Task TestErrorReporting(string testId, DateTime startTime, HttpClient client)
        {
            var polling = new ErrorEventEntryPolling();
            await Assert.ThrowsAsync <Exception>(() => client.GetAsync($"/ErrorReporting/ThrowsException/{testId}"));

            var errorEvents = polling.GetEvents(startTime, testId, 1);

            Assert.Single(errorEvents);
        }
Ejemplo n.º 3
0
        private static async Task TestErrorReporting(string testId, HttpClient client)
        {
            var polling = new ErrorEventEntryPolling();
            await Assert.ThrowsAsync <Exception>(() => client.GetAsync($"/ErrorReporting/{nameof(ErrorReportingController.ThrowsException)}/{testId}"));

            var errorEvent = polling.GetEvents(testId, 1).Single();

            ErrorEventEntryVerifiers.VerifyFullErrorEventLogged(errorEvent, testId, nameof(ErrorReportingController.ThrowsException));
        }
        internal static void PollAndVerifyErrorEvent(DateTime startTime, string testId, string functionName)
        {
            var errorEvents = s_polling.GetEvents(startTime, testId, 1);
            var errorEvent  = errorEvents.Single();

            Assert.Equal(ErrorReportingTestApplication.Service, errorEvent.ServiceContext.Service);
            Assert.Equal(ErrorReportingTestApplication.Version, errorEvent.ServiceContext.Version);

            Assert.Contains(testId, errorEvent.Message);

            Assert.Equal(HttpMethod.Get.Method, errorEvent.Context.HttpRequest.Method);
            Assert.False(string.IsNullOrWhiteSpace(errorEvent.Context.HttpRequest.Url));
            Assert.True(errorEvent.Context.HttpRequest.ResponseStatusCode >= 200);

            if (s_isWindows)
            {
                Assert.False(string.IsNullOrWhiteSpace(errorEvent.Context.ReportLocation.FilePath));
                Assert.True(errorEvent.Context.ReportLocation.LineNumber > 0);
            }
            Assert.Equal(functionName, errorEvent.Context.ReportLocation.FunctionName);
        }