Exemplo n.º 1
0
 /// <summary>
 /// Gets a dynamic implementation that simulates empty log settings configuration.
 /// </summary>
 /// <returns>Dynamic implementation of type LogSettingConfigSection for empty log setting.</returns>
 public static ImplementationOfType GetEmptyLogSettingConfigurationMock()
 {
     ImplementationOfType impl = new ImplementationOfType(typeof(LogSettingConfigSection));
     impl.Register(typeof(LogSettingConfigSection).GetMethod(ConfigurationSectionGetSettingsMethod), null, null, null, RegistrationOptions.None,
                     delegate
                     {
                         LogSettingConfigCollection collection = new LogSettingConfigCollection();
                         return collection;
                     });
     return impl;
 }
Exemplo n.º 2
0
 public void ReturnLogWriterInstanceOfConfiguredTypeWhenGetInstanceIsCalled()
 {
     using (var isolator = new InstanceMethodCallIsolator<LogSettingConfigSection>(LogSettingsConfigSectionGetSettingsMethodName,
         delegate
         {
             // Simulate LogWriter="Microsoft.Support.Workflow.Service.Common.Logging.EventLogWriter,QueryService.Common" value.
             LogSettingConfigCollection collection = new LogSettingConfigCollection();
             collection[LogSettingKey.LogWriter] = new LogSettingConfigElement { Key = LogSettingKey.LogWriter, Value = "Microsoft.Support.Workflow.Service.Common.Logging.EventLogWriter,QueryService.Common" };
             collection[LogSettingKey.LogName] = new LogSettingConfigElement { Key = LogSettingKey.LogName, Value = LogSettingDefaultValue.LogName };
             return collection;
         }))
     {
         ILogWriter writer = LogWriterFactory.LogWriter;
         Assert.IsTrue(writer is EventLogWriter);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a dynamic implementation that simulates a valid log settings configuration.
        /// </summary>
        /// <returns>Dynamic implementation of type LogSettingConfigSection for valid log setting.</returns>
        public static ImplementationOfType GetValidLogSettingConfigurationMock()
        {
            ImplementationOfType impl = new ImplementationOfType(typeof(LogSettingConfigSection));
            impl.Register(typeof(LogSettingConfigSection).GetMethod(ConfigurationSectionGetSettingsMethod), null, null, null, RegistrationOptions.None,
                            delegate
                            {
                               LogSettingConfigCollection collection = new LogSettingConfigCollection();
                                collection[LogSettingKey.LogWriter] = new LogSettingConfigElement { Key = LogSettingKey.LogWriter, Value = "Microsoft.Support.Workflow.Service.Common.Logging.EventLogWriter,QueryService.Common" };
                                collection[LogSettingKey.LogName] = new LogSettingConfigElement { Key = LogSettingKey.LogName, Value = LogSettingDefaultValue.LogName };
                                collection[LogSettingKey.GetLogLevelKey("default")] = new LogSettingConfigElement { Key = "default", Value = "2" };
                                collection[LogSettingKey.GetLogLevelKey(EventSource.DatabaseError.ToString().ToLower())] = new LogSettingConfigElement { Key = LogSettingKey.GetLogLevelKey("default"), Value = "2" };
                                collection[LogSettingKey.GetLogLevelKey(EventSource.DataAccessLayerError.ToString().ToLower())] = new LogSettingConfigElement { Key = LogSettingKey.GetLogLevelKey(EventSource.DataAccessLayerError.ToString().ToLower()), Value = "2" };
                                collection[LogSettingKey.GetLogLevelKey(EventSource.BusinessLayerError.ToString().ToLower())] = new LogSettingConfigElement { Key = LogSettingKey.GetLogLevelKey(EventSource.BusinessLayerError.ToString().ToLower()), Value = "2" };
                                collection[LogSettingKey.GetLogLevelKey(EventSource.WebServiceLayerError.ToString().ToLower())] = new LogSettingConfigElement { Key = LogSettingKey.GetLogLevelKey(EventSource.WebServiceLayerError.ToString().ToLower()), Value = "2" };
                                collection[LogSettingKey.GetLogLevelKey(EventSource.LogWriterError.ToString().ToLower())] = new LogSettingConfigElement { Key = LogSettingKey.GetLogLevelKey(EventSource.LogWriterError.ToString().ToLower()), Value = "2" };
                                collection[LogSettingKey.GetLogLevelKey(EventSource.BusinessLayerValidation.ToString().ToLower())] = new LogSettingConfigElement { Key = LogSettingKey.GetLogLevelKey(EventSource.BusinessLayerValidation.ToString().ToLower()), Value = "-1" };

                                return collection;
                            });
            return impl;
        }
Exemplo n.º 4
0
 public void ReturnNullIfLogWriterConfigValueIsEmptyWhenGetInstanceIsCalled()
 {
     using (var isolator = new InstanceMethodCallIsolator<LogSettingConfigSection>(LogSettingsConfigSectionGetSettingsMethodName,
         delegate
         {
             // Simulate LogWriter="" value.
             LogSettingConfigCollection collection = new LogSettingConfigCollection();
             collection[LogSettingKey.LogWriter] = new LogSettingConfigElement { Key = LogSettingKey.LogWriter, Value = String.Empty };
             collection[LogSettingKey.LogName] = new LogSettingConfigElement { Key = LogSettingKey.LogName, Value = LogSettingDefaultValue.LogName };
             return collection;
         }))
     {
         ILogWriter writer = LogWriterFactory.LogWriter;
         Assert.IsNull(writer);
     }
 }
Exemplo n.º 5
0
 public void ReturnNullIfLogWriterConfigValueIsNotILogWriterWhenGetInstanceIsCalled()
 {
     using (var isolator = new InstanceMethodCallIsolator<LogSettingConfigSection>(LogSettingsConfigSectionGetSettingsMethodName,
         delegate
         {
             // Simulate a log writer value properly defined for an existing type that does not implement ILogWriter.
             LogSettingConfigCollection collection = new LogSettingConfigCollection();
             collection[LogSettingKey.LogWriter] = new LogSettingConfigElement { Key = LogSettingKey.LogWriter, Value = "Microsoft.Support.Workflow.QueryService.Common.BaseException,QueryService.Common" };
             collection[LogSettingKey.LogName] = new LogSettingConfigElement { Key = LogSettingKey.LogName, Value = LogSettingDefaultValue.LogName };
             return collection;
         }))
     {
         ILogWriter writer = LogWriterFactory.LogWriter;
         Assert.IsNull(writer);
     }
 }