Пример #1
0
        public void InProjectTest(string[] projectNamespaces, StackTraceInProjectTestCase[] testCases)
        {
            var configuration = new Configuration("123456")
            {
                ProjectNamespaces = projectNamespaces
            };
            var report = new Report(configuration, new System.Exception(), HandledState.ForHandledException(), new Breadcrumb[0], new Session());

            foreach (var exception in report.Event.Exceptions)
            {
                exception["stacktrace"] = testCases
                                          .Select(t => new StackTraceLine(null, 0, t.MethodName, false, null))
                                          .ToArray();
            }

            InternalMiddleware.DetectInProjectNamespaces(report);

            foreach (var exception in report.Event.Exceptions)
            {
                foreach (var stackTraceLine in exception.StackTrace)
                {
                    foreach (var testCase in testCases)
                    {
                        if (stackTraceLine.MethodName == testCase.MethodName)
                        {
                            Assert.Equal(testCase.ShouldBeMarkedAsInProject, stackTraceLine.InProject);
                        }
                    }
                }
            }
        }
Пример #2
0
        public void HandledExceptionPayloadIsCorrect()
        {
            var handledState = HandledState.ForHandledException();

            Assert.False((bool)handledState["unhandled"]);
            Assert.Equal("warning", handledState["severity"]);
            Assert.Equal(Severity.Warning, handledState.Severity);
        }
Пример #3
0
        public void NonThrownException()
        {
            System.Exception exception = new System.Exception("test");
            var configuration          = new Configuration("123456");

            var report = new Report(configuration, exception, HandledState.ForHandledException(), new Breadcrumb[] { new Breadcrumb("test", BreadcrumbType.Manual) }, new Session());

            Assert.NotNull(report);
        }
Пример #4
0
        public void ContextIsSetByRequest(Request request, string existingContext, string expectedContext)
        {
            var configuration = new Configuration("123456");
            var report        = new Report(configuration, new System.Exception(), HandledState.ForHandledException(), new Breadcrumb[0], new Session());

            report.Event.Context = existingContext;
            report.Event.Request = request;

            Assert.Equal(expectedContext, report.Event.Context);
        }
Пример #5
0
        public void IgnoreClassesTest(System.Exception thrownException, Type ignoreClass, bool ignored)
        {
            var configuration = new Configuration("123456")
            {
                IgnoreClasses = new[] { ignoreClass }
            };
            var report = new Report(configuration, thrownException, HandledState.ForHandledException(), new Breadcrumb[0], new Session());

            InternalMiddleware.CheckIgnoreClasses(report);

            Assert.Equal(ignored, report.Ignored);
        }
Пример #6
0
        public void DetermineDefaultContextTests(string requestUrl, string expectedContext)
        {
            var configuration = new Configuration("123456");
            var report        = new Report(configuration, new System.Exception(), HandledState.ForHandledException(), new Breadcrumb[0], new Session());

            report.Event.Request = new Request {
                Url = requestUrl
            };

            InternalMiddleware.DetermineDefaultContext(report);

            Assert.Equal(expectedContext, report.Event.Context);
        }
Пример #7
0
        public void BasicTest()
        {
            System.Exception exception = null;
            var configuration          = new Configuration("123456");

            try
            {
                throw new System.Exception("test");
            }
            catch (System.Exception caughtException)
            {
                exception = caughtException;
            }

            var report = new Report(configuration, exception, HandledState.ForHandledException(), new Breadcrumb[] { new Breadcrumb("test", BreadcrumbType.Manual) }, new Session());

            Assert.NotNull(report);
        }
Пример #8
0
        public void ProjectRootStrippingTests(string[] projectRoots, string fileName, string expectedFileName)
        {
            var configuration = new Configuration("123456")
            {
                ProjectRoots = projectRoots
            };
            var report = new Report(configuration, new System.Exception(), HandledState.ForHandledException(), new Breadcrumb[0], new Session());

            foreach (var exception in report.Event.Exceptions)
            {
                var stacktrace = new StackTraceLine[] { new StackTraceLine(fileName, 1, string.Empty, false, null) };
                exception["stacktrace"] = stacktrace;
            }

            InternalMiddleware.RemoveProjectRoots(report);

            foreach (var exception in report.Event.Exceptions)
            {
                foreach (var stacktraceline in exception.StackTrace)
                {
                    Assert.Equal(expectedFileName, stacktraceline.FileName);
                }
            }
        }
Пример #9
0
 internal void Notify(System.Exception exception, Middleware callback, int level)
 {
     Notify(exception, HandledState.ForHandledException(), callback, level);
 }
Пример #10
0
 internal void Notify(System.Exception exception, int level)
 {
     Notify(exception, HandledState.ForHandledException(), null, level);
 }