コード例 #1
0
        public void Configure_Test()
        {
            // Arrange
            TestableExceptionWritter writter = new TestableExceptionWritter();

            // Act
            ExceptionHandler.ConfigureFromConfigurationFile(writter);

            // Assert
            Assert.Equal("http://localhost:11079/error/log", writter.RequestUri.ToString());
        }
コード例 #2
0
        public void Should_Call_Completed_Event_Test()
        {
            // Arrange
            ExceptionDefaults parameters = new ExceptionDefaults
            {
                Token = "Test-Token",
                RemoteLogUri = "http://localhost:11079/error/log"
            };

            bool completed = false;
            TestableExceptionWritter writter = new TestableExceptionWritter();
            writter.Completed += (s, e) =>
            {
                completed = true;
            };

            ExceptionHandler.Configure(writter, parameters);

            // Act
            ExceptionHandler.Report(new Exception(), null);

            // Assert
            Assert.True(completed);
        }
コード例 #3
0
        public void Should_Report_If_Enabled_Test()
        {
            // Arrange
            ExceptionDefaults parameters = new ExceptionDefaults
                                               {
                                                   Token = "Test-Token",
                                                   RemoteLogUri = "http://localhost:11079/error/log"
                                               };
            TestableExceptionWritter writter = new TestableExceptionWritter();

            ExceptionHandler.Configure(writter, parameters);

            // Act
            ExceptionHandler.Report(new Exception(), null);

            // Assert
            Assert.NotNull(writter.Error);
        }
コード例 #4
0
        public void Should_Not_Report_If_Disabled_Test()
        {
            // Arrange
            ExceptionDefaults parameters = new ExceptionDefaults
                                               {
                                                   RemoteLogUri = "http://localhost:11079/error/log"
                                               };
            TestableExceptionWritter writter = new TestableExceptionWritter();

            ExceptionHandler.IsEnabled = false;
            ExceptionHandler.Configure(writter, parameters);

            // Act
            ExceptionHandler.Report(new Exception(), null);

            // Reset to default
            ExceptionHandler.IsEnabled = true;

            // Assert
            Assert.Null(writter.Error);
        }