public void Given()
 {
     listenerData = new SystemDiagnosticsTraceListenerData(
          "systemDiagnosticsTraceListener",
          typeof(MockSystemDiagsTraceListener),
          "someInitData"
      );
 }
		public void CanCreateInstanceFromGivenConfiguration()
		{
			SystemDiagnosticsTraceListenerData listenerData
				= new SystemDiagnosticsTraceListenerData("listener", typeof(DelimitedListTraceListener), "log.txt");

			MockLogObjectsHelper helper = new MockLogObjectsHelper();
			TraceListener listener = TraceListenerCustomFactory.Instance.Create(context, listenerData, helper.configurationSource,reflectionCache);

			Assert.IsNotNull(listener);
			Assert.AreEqual("listener", listener.Name);
			Assert.AreEqual(typeof(DelimitedListTraceListener), listener.GetType());
		}
        public void CanCreateInstanceFromGivenName()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(EventLogTraceListener), "Entlib Tests");

            MockLogObjectsHelper helper = new MockLogObjectsHelper();
            helper.loggingSettings.TraceListeners.Add(listenerData);
            TraceListener listener = GetListener("listener", helper.configurationSource);

            Assert.IsNotNull(listener);
            Assert.AreEqual("listener", listener.Name);
            Assert.AreEqual(listener.GetType(), typeof(EventLogTraceListener));
            Assert.AreEqual("Entlib Tests", ((EventLogTraceListener)listener).EventLog.Source);
        }
        public void CanCreateInstanceFromGivenName()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(DelimitedListTraceListener), "log.txt");

            MockLogObjectsHelper helper = new MockLogObjectsHelper();
            helper.loggingSettings.TraceListeners.Add(listenerData);

            TraceListener listener = GetListener("listener", helper.configurationSource);

            Assert.IsNotNull(listener);
            Assert.AreEqual("listener", listener.Name);
            Assert.AreEqual(typeof(DelimitedListTraceListener), listener.GetType());
        }
        public void CanCreateInstanceFromGivenConfiguration()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(TextWriterTraceListener), "log.txt");
            listenerData.TraceOutputOptions = TraceOptions.Callstack;

            MockLogObjectsHelper helper = new MockLogObjectsHelper();

            TraceListener listener = TraceListenerCustomFactory.Instance.Create(context, listenerData, helper.configurationSource,reflectionCache);

            Assert.IsNotNull(listener);
            Assert.AreEqual(listener.GetType(), typeof(TextWriterTraceListener));
            Assert.AreEqual("listener", listener.Name);
            Assert.AreEqual(TraceOptions.Callstack, listener.TraceOutputOptions);
        }
        public void CanCreateInstanceFromConfigurationFile()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(TextWriterTraceListener), "log.txt");
            listenerData.TraceOutputOptions = TraceOptions.Callstack;

            LoggingSettings loggingSettings = new LoggingSettings();
            loggingSettings.TraceListeners.Add(listenerData);

            TraceListener listener
                = TraceListenerCustomFactory.Instance.Create(context, "listener", CommonUtil.SaveSectionsAndGetConfigurationSource(loggingSettings), reflectionCache);

            Assert.IsNotNull(listener);
            Assert.AreEqual(listener.GetType(), typeof(TextWriterTraceListener));
            Assert.AreEqual(TraceOptions.Callstack, listener.TraceOutputOptions);
        }
        public void CanCreateInstanceFromGivenName()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(DelimitedListTraceListener), "log.txt");

            MockLogObjectsHelper helper = new MockLogObjectsHelper();
            helper.loggingSettings.TraceListeners.Add(listenerData);

            var container = EnterpriseLibraryContainer.CreateDefaultContainer(helper.configurationSource);

            TraceListener listener = container.GetInstance<TraceListener>("listener\u200cimplementation");

            Assert.IsNotNull(listener);
            Assert.AreEqual("listener\u200cimplementation", listener.Name);
            Assert.AreEqual(typeof(DelimitedListTraceListener), listener.GetType());
        }
        public void CanCreateInstanceFromGivenName()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(TextWriterTraceListener), "log.txt");
            listenerData.TraceOutputOptions = TraceOptions.Callstack;

            MockLogObjectsHelper helper = new MockLogObjectsHelper();
            helper.loggingSettings.TraceListeners.Add(listenerData);

            TraceListener listener = GetListener("listener\u200cimplementation", helper.configurationSource);

            Assert.IsNotNull(listener);
            Assert.AreEqual(listener.GetType(), typeof(TextWriterTraceListener));
            Assert.AreEqual("listener\u200cimplementation", listener.Name);
            Assert.AreEqual(TraceOptions.Callstack, listener.TraceOutputOptions);
        }
        public void CanCreateInstanceFromConfigurationFile()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(DelimitedListTraceListener), "log.txt");
            listenerData.SetAttributeValue("delimiter", "||");
            LoggingSettings loggingSettings = new LoggingSettings();
            loggingSettings.TraceListeners.Add(listenerData);

            TraceListener listener
                = TraceListenerCustomFactory.Instance.Create(context, "listener", CommonUtil.SaveSectionsAndGetConfigurationSource(loggingSettings), reflectionCache);

            Assert.IsNotNull(listener);
            Assert.AreEqual("listener", listener.Name);
            Assert.AreEqual(typeof(DelimitedListTraceListener), listener.GetType());
            Assert.AreEqual("||", ((DelimitedListTraceListener)listener).Delimiter);
        }
        public void CanCreateInstanceFromConfigurationFile()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(DelimitedListTraceListener), "log.txt");
            listenerData.SetAttributeValue("delimiter", "||");
            LoggingSettings loggingSettings = new LoggingSettings();
            loggingSettings.TraceListeners.Add(listenerData);

            TraceListener listener = GetListener("listener", CommonUtil.SaveSectionsAndGetConfigurationSource(loggingSettings));

            Assert.IsNotNull(listener);
            Assert.AreEqual("listener", listener.Name);

            var innerListener = (DelimitedListTraceListener)listener;

            Assert.AreEqual("||", innerListener.Delimiter);
        }
        public void CanCreateInstanceFromGivenConfigurationWithAttributes()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(DelimitedListTraceListener), "log.txt");
            listenerData.SetAttributeValue("delimiter", "||");

            MockLogObjectsHelper helper = new MockLogObjectsHelper();
            helper.loggingSettings.TraceListeners.Add(listenerData);

            TraceListener listener = GetListener("listener", helper.configurationSource);

            Assert.IsNotNull(listener);
            Assert.AreEqual("listener", listener.Name);

            var innerListener = (DelimitedListTraceListener)listener;
            Assert.AreEqual("||", innerListener.Delimiter);
        }
        public void CanCreateInstanceFromGivenConfigurationWithAttributes()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(DelimitedListTraceListener), "log.txt");
            listenerData.SetAttributeValue("delimiter", "||");

            MockLogObjectsHelper helper = new MockLogObjectsHelper();
            helper.loggingSettings.TraceListeners.Add(listenerData);

            var container = EnterpriseLibraryContainer.CreateDefaultContainer(helper.configurationSource);

            TraceListener listener = container.GetInstance<TraceListener>("listener\u200cimplementation");

            Assert.IsNotNull(listener);
            Assert.AreEqual("listener\u200cimplementation", listener.Name);
            Assert.IsInstanceOfType(listener, typeof(AttributeSettingTraceListenerWrapper));

            var innerListener =
                (DelimitedListTraceListener)((AttributeSettingTraceListenerWrapper)listener).InnerTraceListener;
            Assert.AreEqual("||", innerListener.Delimiter);
        }
        public void CanCreateInstanceFromConfigurationFile()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(DelimitedListTraceListener), "log.txt");
            listenerData.SetAttributeValue("delimiter", "||");
            LoggingSettings loggingSettings = new LoggingSettings();
            loggingSettings.TraceListeners.Add(listenerData);

            var container = EnterpriseLibraryContainer.CreateDefaultContainer(CommonUtil.SaveSectionsAndGetConfigurationSource(loggingSettings));

            TraceListener listener = container.GetInstance<TraceListener>("listener\u200cimplementation");

            Assert.IsNotNull(listener);
            Assert.AreEqual("listener\u200cimplementation", listener.Name);
            Assert.IsInstanceOfType(listener, typeof(AttributeSettingTraceListenerWrapper));

            var innerListener =
                (DelimitedListTraceListener)((AttributeSettingTraceListenerWrapper)listener).InnerTraceListener;

            Assert.AreEqual("||", innerListener.Delimiter);
        }
 public void Given()
 {
     listenerData = new SystemDiagnosticsTraceListenerData(
         "systemDiagnosticsTraceListener",
         typeof(MockSystemDiagsTraceListener),
         "initData");
     listenerData.Attributes.Add("checkone", "one");
     listenerData.Attributes.Add("checktwo", "two");
 }
 public void WhenCreatingInstanceUsingDefaultContructor_ThenListenerDataTypeIsSet()
 {
     var listener = new SystemDiagnosticsTraceListenerData();
     Assert.AreEqual(typeof(SystemDiagnosticsTraceListenerData), listener.ListenerDataType);
 }
 public void Given()
 {
     this.listenerData = new SystemDiagnosticsTraceListenerData(
         "systemDiagnosticsTraceListener",
         typeof(MockSystemDiagsTraceListener),
         "initData",
         TraceOptions.ProcessId | TraceOptions.Callstack
         );
     listenerData.Filter = SourceLevels.Critical;
 }
        public void Given()
        {
            var listenerData = new SystemDiagnosticsTraceListenerData(
                "systemDiagnosticsTraceListener",
                typeof(System.Diagnostics.TextWriterTraceListener),
                "initData",
                TraceOptions.ProcessId | TraceOptions.Callstack
                );

            listenerData.Filter = SourceLevels.Critical;
            registryEntry = 
                listenerData.GetRegistrations().Where(tr => tr.Name == "systemDiagnosticsTraceListener\u200Cimplementation").First();
            wrapperRegistryEntry =
                listenerData.GetRegistrations().Where(tr => tr.Name == "systemDiagnosticsTraceListener").First();
        }
        public void CanCreatePoliciesForSysDiagsTraceListenerWithoutInitData()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(MockCustomTraceListener), "", TraceOptions.Callstack);
            listenerData.SetAttributeValue(MockCustomTraceListener.AttributeKey, attributeValue);
            loggingSettings.TraceListeners.Add(listenerData);

            using (var container = CreateContainer())
            {
                AttributeSettingTraceListenerWrapper createdObject =
                    container.Resolve<TraceListener>("listener\u200cimplementation") as AttributeSettingTraceListenerWrapper;

                Assert.IsNotNull(createdObject);
                Assert.AreEqual("listener\u200cimplementation", createdObject.Name);
                Assert.AreEqual(TraceOptions.Callstack, createdObject.TraceOutputOptions);
                Assert.AreEqual(typeof(MockCustomTraceListener), createdObject.InnerTraceListener.GetType());
                Assert.AreEqual(null, ((MockCustomTraceListener)createdObject.InnerTraceListener).initData);	// configured with "", but set to null
                Assert.AreEqual(attributeValue, ((MockCustomTraceListener)createdObject.InnerTraceListener).Attribute);
            }
        }
        public void CanCreateInstanceFromConfigurationFileUsingSystemDiagnosticsTraceListenerData()
        {
            SystemDiagnosticsTraceListenerData listenerData
                = new SystemDiagnosticsTraceListenerData("listener", typeof(MockCustomTraceListener), initializationData, TraceOptions.Callstack);
            listenerData.SetAttributeValue(MockCustomTraceListener.AttributeKey, attributeValue);
            LoggingSettings loggingSettings = new LoggingSettings();
            loggingSettings.TraceListeners.Add(listenerData);

            TraceListener listener = GetListener("listener", CommonUtil.SaveSectionsAndGetConfigurationSource(loggingSettings));

            Assert.IsNotNull(listener);
            Assert.AreEqual("listener", listener.Name);
            Assert.AreEqual(TraceOptions.Callstack, listener.TraceOutputOptions);

            var innerListener = (MockCustomTraceListener)listener;

            Assert.AreEqual(initializationData, innerListener.initData);
            Assert.AreEqual(attributeValue, innerListener.Attribute);
        }
 public void Given()
 {
     listenerData = new SystemDiagnosticsTraceListenerData(
          "systemDiagnosticsTraceListener",
          typeof(System.Diagnostics.TextWriterTraceListener),
          "someInitData"
      );
 }