示例#1
0
        public void ProcessEvent_WithCorrectlyConfiguredProviderWithNoProviderSet_LogsToDefaultProvider()
        {
            using (var scope = new LoggingProviderScope(ScopeOption.AllowOnlyASingleEntryToBeLogged))
            {
                // Arrange
                var          provider = CreateInitializedProvider();
                WebBaseEvent webEvent = new DerivedWebErrorEvent("Valid message", null, 1, new Exception());

                // Act
                provider.ProcessEvent(webEvent);

                // Assert
                Assert.AreEqual(1, scope.LoggedEntries.Count);
            }
        }
示例#2
0
        public void ProcessEvent_WithDerivedWebErrorEvent_LogsExpectedEntry()
        {
            using (var scope = new LoggingProviderScope(ScopeOption.AllowOnlyASingleEntryToBeLogged))
            {
                // Arrange
                var          expectedSeverity = LoggingEventType.Error;
                var          provider         = CreateInitializedProvider();
                WebBaseEvent webEvent         = new DerivedWebErrorEvent("Valid message", null, 1, new Exception());

                // Act
                provider.ProcessEvent(webEvent);

                // Assert
                var loggedEntry = scope.LoggedEntries.First();
                Assert.AreEqual(expectedSeverity, loggedEntry.Severity);
                Assert.IsNotNull(loggedEntry.Exception);
            }
        }
示例#3
0
        public void ProcessEvent_WithCorrectlyConfiguredProviderWithProviderSet_LogsToExpectedProvider()
        {
            using (var scope = new LoggingProviderScope(ScopeOption.AllowOnlyASingleEntryToBeLogged))
            {
                // Arrange
                var provider      = new LoggingWebEventProvider();
                var configuration = new NameValueCollection();
                configuration.Add("loggingProvider", "UnitTestingLoggingProvider");
                provider.Initialize("Valid name", configuration);
                WebBaseEvent webEvent = new DerivedWebErrorEvent("Valid message", null, 1, new Exception());

                // Act
                provider.ProcessEvent(webEvent);

                // Assert
                Assert.AreEqual(1, scope.LoggedEntries.Count);
            }
        }