Exemplo n.º 1
0
        public void Initialize_WithNullConfiguration_ThrowsException()
        {
            // Arrange
            var provider = new LoggingWebEventProvider();

            // Act
            provider.Initialize("Valid name", null);
        }
Exemplo n.º 2
0
        private static LoggingWebEventProvider CreateInitializedProvider()
        {
            var provider = new LoggingWebEventProvider();

            provider.Initialize("Valid name", new NameValueCollection());

            return(provider);
        }
Exemplo n.º 3
0
        public void Initialize_WithValidArguments_Succeeds()
        {
            // Arrange
            var provider           = new LoggingWebEventProvider();
            var validProviderName  = "Valid name";
            var validConfiguration = CreateValidConfiguration();

            // Act
            provider.Initialize(validProviderName, validConfiguration);
        }
Exemplo n.º 4
0
        public void Initialize_WithUnrecognizedAttribute_ThrowsException()
        {
            // Arrange
            var provider             = new LoggingWebEventProvider();
            var validProviderName    = "Valid name";
            var invalidConfiguration = CreateValidConfiguration();

            invalidConfiguration.Add("bad attribute", "bad value");

            // Act
            provider.Initialize(validProviderName, invalidConfiguration);
        }
Exemplo n.º 5
0
        public void Initialize_ConfigurationWithoutDescription_SetsDefaultDescription()
        {
            // Arrange
            var expectedDescription = "Logging Web Event Provider";
            var provider            = new LoggingWebEventProvider();
            var validConfiguration  = CreateValidConfiguration();

            // Act
            provider.Initialize("Valid provider name", validConfiguration);

            // Assert
            Assert.AreEqual(expectedDescription, provider.Description);
        }
Exemplo n.º 6
0
        public void Initialize_WithIncorrectLoggingProviderName_LogsToExpectedProvider()
        {
            using (var scope = new LoggingProviderScope(ScopeOption.AllowOnlyASingleEntryToBeLogged))
            {
                // Arrange
                var provider             = new LoggingWebEventProvider();
                var invalidConfiguration = CreateValidConfiguration();
                invalidConfiguration.Add("loggingProvider", "NON EXISTING PROVIDER");

                // Act
                provider.Initialize("Valid name", invalidConfiguration);
            }
        }
Exemplo n.º 7
0
        public void Initialize_WithEmptyProviderName_GetsTypeNameAsProviderName()
        {
            // Arrange
            var expectedProviderName   = "LoggingWebEventProvider";
            var provider               = new LoggingWebEventProvider();
            var validEmptyProviderName = string.Empty;
            var validConfiguration     = CreateValidConfiguration();

            // Act
            provider.Initialize(validEmptyProviderName, validConfiguration);

            // Arrange
            Assert.AreEqual(expectedProviderName, provider.Name);
        }
Exemplo n.º 8
0
        public void Initialize_ConfigurationWithCustomDescription_SetsSpecifiedDescription()
        {
            // Arrange
            var expectedDescription = "My web app trace logging provider";
            var provider            = new LoggingWebEventProvider();
            var validConfiguration  = CreateValidConfiguration();

            validConfiguration["description"] = expectedDescription;

            // Act
            provider.Initialize("Valid provider name", validConfiguration);

            // Assert
            Assert.AreEqual(expectedDescription, provider.Description);
        }
Exemplo n.º 9
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);
            }
        }