Ejemplo n.º 1
0
 public void AddLogEventWithExceptionNull_ShouldThrow_ArgumentNullException()
 {
     // Arrange
     // Act
     // Assert
     Assert.Throws <ArgumentNullException>(() =>
                                           ExceptionDataExtensions.AddLogEvent(
                                               null,
                                               StandardLoglevel.Warning));
 }
Ejemplo n.º 2
0
        public void AddLogEventWithTimeNull_Should_UseCurrentTime()
        {
            // Arrange
            var exception = new InvalidOperationException();

            // Act
            var logEvent = ExceptionDataExtensions.AddLogEvent(
                exception,
                StandardLoglevel.Warning);

            // Assert
            logEvent.Time.Should().BeCloseTo(DateTime.Now, TimeSpan.FromSeconds(1));
        }
Ejemplo n.º 3
0
        public void AddLogEvent_Should_CreateLogEventInExceptionDataDictionary()
        {
            // Arrange
            var exception = new InvalidOperationException();

            // Act
            var logEvent = ExceptionDataExtensions.AddLogEvent(
                exception,
                StandardLoglevel.Warning);

            // Assert
            exception.Data[typeof(LogEvent <StandardLoglevel>)].Should().BeSameAs(logEvent);
        }
Ejemplo n.º 4
0
        public void AddLogEventTwice_Should_OverwriteFirstDataDictionaryInException()
        {
            // Arrange
            var exception = new InvalidOperationException();

            // Act
            var logEvent1 = ExceptionDataExtensions.AddLogEvent(
                exception,
                StandardLoglevel.Warning);
            var logEvent2 = ExceptionDataExtensions.AddLogEvent(
                exception,
                StandardLoglevel.Error);

            // Assert
            exception.Data[typeof(LogEvent <StandardLoglevel>)].Should().BeSameAs(logEvent2);
        }
Ejemplo n.º 5
0
        public async Task AddLogEvent_Should_LogThisLogEventAutomaticallyAfterTheLogEventContainingTheExceptionDetails()
        {
            // Arrange
            var logfileConfigurationBuilder = new LogfileConfigurationBuilder <StandardLoglevel>();

            logfileConfigurationBuilder
            .AddPreprocessor(ExtractLogEventsFromExceptions <StandardLoglevel> .Instance);

            var logfile = new Logfile <StandardLoglevel>();
            await logfile.ReconfigureAsync(logfileConfigurationBuilder.Build(), default);

            var exception = new InvalidOperationException();

            // Act
            var logEvent = ExceptionDataExtensions.AddLogEvent(
                exception,
                StandardLoglevel.Warning);

            // Assert
            exception.Data[typeof(LogEvent <StandardLoglevel>)].Should().BeSameAs(logEvent);
        }