示例#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);
                        }
                    }
                }
            }
        }
        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);
 }