public MsmqTraceListenerSetting(MsmqTraceListenerData sourceElement, string name, string formatter, string messagePriority, string queuePath, bool recoverable, string timeToBeReceived, string timeToReachQueue, string traceOutputOptions, string transactionType, bool useAuthentication, bool useDeadLetterQueue, bool useEncryption, string filter) : base(sourceElement, name, traceOutputOptions, filter) { this.formatter = formatter; this.messagePriority = messagePriority; this.queuePath = queuePath; this.recoverable = recoverable; this.timeToBeReceived = timeToBeReceived; this.timeToReachQueue = timeToReachQueue; this.transactionType = transactionType; this.useAuthentication = useAuthentication; this.useDeadLetterQueue = useDeadLetterQueue; this.useEncryption = useEncryption; }
public void CanDeserializeSerializedConfigurationWithDefaults() { LoggingSettings rwLoggingSettings = new LoggingSettings(); rwLoggingSettings.TraceListeners.Add(new MsmqTraceListenerData("listener", CommonUtil.MessageQueuePath, formatterName)); IDictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>(); sections[LoggingSettings.SectionName] = rwLoggingSettings; IConfigurationSource configurationSource = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections); LoggingSettings roLoggingSettings = (LoggingSettings)configurationSource.GetSection(LoggingSettings.SectionName); Assert.AreEqual(1, roLoggingSettings.TraceListeners.Count); Assert.IsNotNull(roLoggingSettings.TraceListeners.Get("listener")); Assert.AreEqual(roLoggingSettings.TraceListeners.Get("listener").GetType(), typeof(MsmqTraceListenerData)); MsmqTraceListenerData listenerData = roLoggingSettings.TraceListeners.Get("listener") as MsmqTraceListenerData; Assert.AreEqual("listener", listenerData.Name); Assert.AreEqual(formatterName, listenerData.Formatter); Assert.AreEqual(CommonUtil.MessageQueuePath, listenerData.QueuePath); Assert.AreEqual(MsmqTraceListenerData.DefaultRecoverable, listenerData.Recoverable); Assert.AreEqual(MsmqTraceListenerData.DefaultUseAuthentication, listenerData.UseAuthentication); Assert.AreEqual(MsmqTraceListenerData.DefaultUseDeadLetter, listenerData.UseDeadLetterQueue); Assert.AreEqual(MsmqTraceListenerData.DefaultUseEncryption, listenerData.UseEncryption); Assert.AreEqual(MsmqTraceListenerData.DefaultPriority, listenerData.MessagePriority); Assert.AreEqual(MsmqTraceListenerData.DefaultTimeToBeReceived, listenerData.TimeToBeReceived); Assert.AreEqual(MsmqTraceListenerData.DefaultTimeToBeReceived, listenerData.TimeToBeReceived); Assert.AreEqual(TraceOptions.None, listenerData.TraceOutputOptions); }
public void CanCreatePoliciesForMsmqTraceListenerWithFormatter() { MsmqTraceListenerData listenerData = new MsmqTraceListenerData("listener", CommonUtil.MessageQueuePath, "binary"); listenerData.TraceOutputOptions = TraceOptions.Callstack | TraceOptions.ProcessId; listenerData.Filter = SourceLevels.Error; loggingSettings.TraceListeners.Add(listenerData); loggingSettings.Formatters.Add(new BinaryLogFormatterData("binary")); using (var container = CreateContainer()) { MsmqTraceListener createdObject = (MsmqTraceListener)container.Resolve <TraceListener>("listener\u200cimplementation"); Assert.IsNotNull(createdObject); Assert.AreEqual(listenerData.TraceOutputOptions, createdObject.TraceOutputOptions); Assert.IsNotNull(createdObject.Filter); Assert.IsInstanceOfType(createdObject.Filter, typeof(EventTypeFilter)); Assert.AreEqual(listenerData.Filter, ((EventTypeFilter)createdObject.Filter).EventType); Assert.IsNotNull(createdObject.Formatter); Assert.IsInstanceOfType(createdObject.Formatter, typeof(BinaryLogFormatter)); Assert.AreEqual(CommonUtil.MessageQueuePath, createdObject.QueuePath); } // there's currently no way to test for other properties }
internal static bool SaveChanges(MsmqTraceListenerSetting setting, ConfigurationElement sourceElement) { MsmqTraceListenerData element = (MsmqTraceListenerData)sourceElement; element.Filter = ParseHelper.ParseEnum <SourceLevels>(setting.Filter, false); element.Formatter = setting.Formatter; element.MessagePriority = ParseHelper.ParseEnum <MessagePriority>(setting.MessagePriority, false); element.Name = setting.Name; element.QueuePath = setting.QueuePath; element.Recoverable = setting.Recoverable; element.TimeToBeReceived = TimeSpan.Parse(setting.TimeToBeReceived); element.TimeToReachQueue = TimeSpan.Parse(setting.TimeToReachQueue); element.TraceOutputOptions = ParseHelper.ParseEnum <TraceOptions>(setting.TraceOutputOptions, false); element.TransactionType = ParseHelper.ParseEnum <MessageQueueTransactionType>(setting.TransactionType, false); element.UseAuthentication = setting.UseAuthentication; element.UseDeadLetterQueue = setting.UseDeadLetterQueue; element.UseEncryption = setting.UseEncryption; SourceLevels filter; if (ParseHelper.TryParseEnum(setting.Filter, out filter)) { element.Filter = filter; } return(true); }
public void SetUp() { provider = new ConfigurationElementManageabilityProviderWrapper(new MsmqTraceListenerDataManageabilityProvider()); machineKey = new MockRegistryKey(true); userKey = new MockRegistryKey(true); wmiSettings = new List <ConfigurationSetting>(); configurationObject = new MsmqTraceListenerData(); }
public void SetUp() { provider = new MsmqTraceListenerDataManageabilityProvider(); machineKey = new MockRegistryKey(true); machineOptionsKey = new MockRegistryKey(false); userKey = new MockRegistryKey(true); userOptionsKey = new MockRegistryKey(false); configurationObject = new MsmqTraceListenerData(); }
public SendToMsmqTraceListenerBuilder(ILoggingConfigurationSendTo context, string listenerName) : base(context) { msmqTraceListener = new MsmqTraceListenerData { Name = listenerName }; base.AddTraceListenerToSettingsAndCategory(msmqTraceListener); }
/// <summary> /// Initialize a new instance of the <see cref="MsmqTraceListenerNode"/> class with a <see cref="MsmqTraceListenerData"/> instance. /// </summary> /// <param name="msmqTraceListenerData">A <see cref="MsmqTraceListenerData"/> instance.</param> public MsmqTraceListenerNode(MsmqTraceListenerData msmqTraceListenerData) { if (null == msmqTraceListenerData) throw new ArgumentNullException("msmqTraceListenerData"); Rename(msmqTraceListenerData.Name); TraceOutputOptions = msmqTraceListenerData.TraceOutputOptions; this.useEncryption = msmqTraceListenerData.UseEncryption; this.useDeadLetterQueue = msmqTraceListenerData.UseDeadLetterQueue; this.useAuthentication = msmqTraceListenerData.UseAuthentication; this.transactionType = msmqTraceListenerData.TransactionType; this.messagePriority = msmqTraceListenerData.MessagePriority; this.timeToReachQueue = msmqTraceListenerData.TimeToReachQueue; this.timeToBeReceived = msmqTraceListenerData.TimeToBeReceived; this.recoverable = msmqTraceListenerData.Recoverable; this.queuePath = msmqTraceListenerData.QueuePath; this.formatterName = msmqTraceListenerData.Formatter; }
public static void GenerateWmiObjects(MsmqTraceListenerData configurationObject, ICollection <ConfigurationSetting> wmiSettings) { wmiSettings.Add( new MsmqTraceListenerSetting(configurationObject, configurationObject.Name, configurationObject.Formatter, configurationObject.MessagePriority.ToString(), configurationObject.QueuePath, configurationObject.Recoverable, Convert.ToString(configurationObject.TimeToBeReceived, CultureInfo.CurrentCulture), Convert.ToString(configurationObject.TimeToReachQueue, CultureInfo.CurrentCulture), configurationObject.TraceOutputOptions.ToString(), configurationObject.TransactionType.ToString(), configurationObject.UseAuthentication, configurationObject.UseDeadLetterQueue, configurationObject.UseEncryption, configurationObject.Filter.ToString())); }
public void CanDeserializeSerializedConfiguration() { string name = "name"; bool recoverable = true; bool authentication = false; bool deadLetter = true; bool encryption = false; MessageQueueTransactionType transactionType = MessageQueueTransactionType.Automatic; TraceListenerData data = new MsmqTraceListenerData(name, CommonUtil.MessageQueuePath, formatterName, priority, recoverable, timeSpan, timeSpan, authentication, deadLetter, encryption, transactionType, TraceOptions.Callstack, SourceLevels.Critical); LoggingSettings settings = new LoggingSettings(); settings.TraceListeners.Add(data); IDictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>(); sections[LoggingSettings.SectionName] = settings; IConfigurationSource configurationSource = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections); LoggingSettings roSettigs = (LoggingSettings)configurationSource.GetSection(LoggingSettings.SectionName); Assert.AreEqual(1, roSettigs.TraceListeners.Count); Assert.IsNotNull(roSettigs.TraceListeners.Get(name)); Assert.AreEqual(TraceOptions.Callstack, roSettigs.TraceListeners.Get(name).TraceOutputOptions); Assert.AreEqual(SourceLevels.Critical, roSettigs.TraceListeners.Get(name).Filter); Assert.AreSame(typeof(MsmqTraceListenerData), roSettigs.TraceListeners.Get(name).GetType()); Assert.AreSame(typeof(MsmqTraceListenerData), roSettigs.TraceListeners.Get(name).ListenerDataType); Assert.AreSame(typeof(MsmqTraceListener), roSettigs.TraceListeners.Get(name).Type); Assert.AreEqual(formatterName, ((MsmqTraceListenerData)roSettigs.TraceListeners.Get(name)).Formatter); Assert.AreEqual(CommonUtil.MessageQueuePath, ((MsmqTraceListenerData)roSettigs.TraceListeners.Get(name)).QueuePath); Assert.AreEqual(recoverable, ((MsmqTraceListenerData)roSettigs.TraceListeners.Get(name)).Recoverable); Assert.AreEqual(authentication, ((MsmqTraceListenerData)roSettigs.TraceListeners.Get(name)).UseAuthentication); Assert.AreEqual(deadLetter, ((MsmqTraceListenerData)roSettigs.TraceListeners.Get(name)).UseDeadLetterQueue); Assert.AreEqual(encryption, ((MsmqTraceListenerData)roSettigs.TraceListeners.Get(name)).UseEncryption); Assert.AreEqual(priority, ((MsmqTraceListenerData)roSettigs.TraceListeners.Get(name)).MessagePriority); Assert.AreEqual(timeSpan, ((MsmqTraceListenerData)roSettigs.TraceListeners.Get(name)).TimeToBeReceived); Assert.AreEqual(timeSpan, ((MsmqTraceListenerData)roSettigs.TraceListeners.Get(name)).TimeToBeReceived); Assert.AreEqual(transactionType, ((MsmqTraceListenerData)roSettigs.TraceListeners.Get(name)).TransactionType); }
public void SavesChangesToConfigurationObject() { MsmqTraceListenerData sourceElement = new MsmqTraceListenerData(); sourceElement.Formatter = "formatter"; sourceElement.MessagePriority = MessagePriority.AboveNormal; sourceElement.QueuePath = "path"; sourceElement.Recoverable = false; sourceElement.TimeToBeReceived = new TimeSpan(1000); sourceElement.TimeToReachQueue = new TimeSpan(2000); sourceElement.Filter = SourceLevels.Information; sourceElement.TraceOutputOptions = TraceOptions.ProcessId; sourceElement.TransactionType = MessageQueueTransactionType.Automatic; sourceElement.UseAuthentication = false; sourceElement.UseDeadLetterQueue = true; sourceElement.UseEncryption = false; List <ConfigurationSetting> settings = new List <ConfigurationSetting>(1); MsmqTraceListenerDataWmiMapper.GenerateWmiObjects(sourceElement, settings); Assert.AreEqual(1, settings.Count); MsmqTraceListenerSetting setting = settings[0] as MsmqTraceListenerSetting; Assert.IsNotNull(setting); setting.Formatter = "updated formatter"; setting.MessagePriority = MessagePriority.High.ToString(); setting.QueuePath = "updated queue"; setting.Recoverable = true; setting.TimeToBeReceived = new TimeSpan(10000).ToString(); setting.TimeToReachQueue = new TimeSpan(20000).ToString(); setting.Filter = SourceLevels.All.ToString(); setting.TraceOutputOptions = TraceOptions.ThreadId.ToString(); setting.Name = "Foo"; setting.Commit(); Assert.AreEqual(setting.Name, sourceElement.Name); Assert.AreEqual(setting.Filter, sourceElement.Filter.ToString()); Assert.AreEqual(setting.MessagePriority, sourceElement.MessagePriority.ToString()); Assert.AreEqual(setting.Recoverable, sourceElement.Recoverable); Assert.AreEqual(setting.TimeToBeReceived, sourceElement.TimeToBeReceived.ToString()); Assert.AreEqual(setting.TimeToReachQueue, sourceElement.TimeToReachQueue.ToString()); Assert.AreEqual("updated queue", sourceElement.QueuePath); Assert.AreEqual(SourceLevels.All, sourceElement.Filter); Assert.AreEqual(TraceOptions.ThreadId, sourceElement.TraceOutputOptions); }
public void ListenerDataIsCreatedCorrectlyWithDefaults() { MsmqTraceListenerData listenerData = new MsmqTraceListenerData("listener", CommonUtil.MessageQueuePath, formatterName); Assert.AreSame(typeof(MsmqTraceListener), listenerData.Type); Assert.AreSame(typeof(MsmqTraceListenerData), listenerData.ListenerDataType); Assert.AreEqual("listener", listenerData.Name); Assert.AreEqual(formatterName, listenerData.Formatter); Assert.AreEqual(CommonUtil.MessageQueuePath, listenerData.QueuePath); Assert.AreEqual(MsmqTraceListenerData.DefaultRecoverable, listenerData.Recoverable); Assert.AreEqual(MsmqTraceListenerData.DefaultUseAuthentication, listenerData.UseAuthentication); Assert.AreEqual(MsmqTraceListenerData.DefaultUseDeadLetter, listenerData.UseDeadLetterQueue); Assert.AreEqual(MsmqTraceListenerData.DefaultUseEncryption, listenerData.UseEncryption); Assert.AreEqual(MsmqTraceListenerData.DefaultPriority, listenerData.MessagePriority); Assert.AreEqual(MsmqTraceListenerData.DefaultTimeToBeReceived, listenerData.TimeToBeReceived); Assert.AreEqual(MsmqTraceListenerData.DefaultTimeToBeReceived, listenerData.TimeToBeReceived); Assert.AreEqual(MsmqTraceListenerData.DefaultTransactionType, listenerData.TransactionType); Assert.AreEqual(TraceOptions.None, listenerData.TraceOutputOptions); }
public void CanCreateInstanceFromGivenConfiguration() { TraceListenerData listenerData = new MsmqTraceListenerData("listener", CommonUtil.MessageQueuePath, formatterName); MockLogObjectsHelper helper = new MockLogObjectsHelper(); helper.loggingSettings.Formatters.Add(new BinaryLogFormatterData(formatterName)); TraceListener listener = TraceListenerCustomFactory.Instance.Create(context, listenerData, helper.configurationSource, reflectionCache); Assert.IsNotNull(listener); Assert.AreEqual(listener.GetType(), typeof(MsmqTraceListener)); MsmqTraceListener msmqTraceListener = listener as MsmqTraceListener; Assert.AreEqual("listener", listener.Name); Assert.IsNotNull(msmqTraceListener.Formatter); Assert.AreEqual(msmqTraceListener.Formatter.GetType(), typeof(BinaryLogFormatter)); Assert.AreEqual(CommonUtil.MessageQueuePath, msmqTraceListener.QueuePath); }
/// <summary> /// Initialize a new instance of the <see cref="MsmqTraceListenerNode"/> class with a <see cref="MsmqTraceListenerData"/> instance. /// </summary> /// <param name="msmqTraceListenerData">A <see cref="MsmqTraceListenerData"/> instance.</param> public MsmqTraceListenerNode(MsmqTraceListenerData msmqTraceListenerData) { if (null == msmqTraceListenerData) { throw new ArgumentNullException("msmqTraceListenerData"); } Rename(msmqTraceListenerData.Name); TraceOutputOptions = msmqTraceListenerData.TraceOutputOptions; this.useEncryption = msmqTraceListenerData.UseEncryption; this.useDeadLetterQueue = msmqTraceListenerData.UseDeadLetterQueue; this.useAuthentication = msmqTraceListenerData.UseAuthentication; this.transactionType = msmqTraceListenerData.TransactionType; this.messagePriority = msmqTraceListenerData.MessagePriority; this.timeToReachQueue = msmqTraceListenerData.TimeToReachQueue; this.timeToBeReceived = msmqTraceListenerData.TimeToBeReceived; this.recoverable = msmqTraceListenerData.Recoverable; this.queuePath = msmqTraceListenerData.QueuePath; this.formatterName = msmqTraceListenerData.Formatter; }
public void MsmqTraceListenerNodeTest() { string name = "some name"; string messageQueuePath = "some mq path"; bool useDeadLetterQueue = true; bool useAuthentication = true; bool useEncryption = true; bool recoverable = false; TimeSpan timeToBeReceived = new TimeSpan(123); TimeSpan timeToReachQueue = new TimeSpan(123); MessagePriority messagePriority = MessagePriority.VeryHigh; MessageQueueTransactionType transactionType = MessageQueueTransactionType.Automatic; MsmqTraceListenerNode msmqTraceListenerNode = new MsmqTraceListenerNode(); msmqTraceListenerNode.Name = name; msmqTraceListenerNode.QueuePath = messageQueuePath; msmqTraceListenerNode.MessagePriority = messagePriority; msmqTraceListenerNode.TransactionType = transactionType; msmqTraceListenerNode.UseEncryption = useEncryption; msmqTraceListenerNode.UseAuthentication = useAuthentication; msmqTraceListenerNode.UseDeadLetterQueue = useDeadLetterQueue; msmqTraceListenerNode.TimeToReachQueue = timeToReachQueue; msmqTraceListenerNode.TimeToBeReceived = timeToBeReceived; msmqTraceListenerNode.Recoverable = recoverable; ApplicationNode.AddNode(msmqTraceListenerNode); MsmqTraceListenerData nodeData = (MsmqTraceListenerData)msmqTraceListenerNode.TraceListenerData; Assert.AreEqual(name, nodeData.Name); Assert.AreEqual(messageQueuePath, nodeData.QueuePath); Assert.AreEqual(transactionType, nodeData.TransactionType); Assert.AreEqual(messagePriority, nodeData.MessagePriority); Assert.AreEqual(useDeadLetterQueue, nodeData.UseDeadLetterQueue); Assert.AreEqual(useAuthentication, nodeData.UseAuthentication); Assert.AreEqual(useEncryption, nodeData.UseEncryption); Assert.AreEqual(timeToBeReceived, nodeData.TimeToBeReceived); Assert.AreEqual(timeToReachQueue, nodeData.TimeToReachQueue); Assert.AreEqual(recoverable, nodeData.Recoverable); }
public void CanCreateInstanceFromGivenName() { TraceListenerData listenerData = new MsmqTraceListenerData("listener", CommonUtil.MessageQueuePath, formatterName); MockLogObjectsHelper helper = new MockLogObjectsHelper(); helper.loggingSettings.TraceListeners.Add(listenerData); helper.loggingSettings.Formatters.Add(new BinaryLogFormatterData(formatterName)); TraceListener listener = GetListener("listener\u200cimplementation", helper.configurationSource); Assert.IsNotNull(listener); Assert.AreEqual(listener.GetType(), typeof(MsmqTraceListener)); MsmqTraceListener msmqTraceListener = listener as MsmqTraceListener; Assert.AreEqual("listener\u200cimplementation", listener.Name); Assert.IsNotNull(msmqTraceListener.Formatter); Assert.AreEqual(msmqTraceListener.Formatter.GetType(), typeof(BinaryLogFormatter)); Assert.AreEqual(CommonUtil.MessageQueuePath, msmqTraceListener.QueuePath); }
public void MsmqTraceListenerNodeDataTest() { string name = "some name"; string messageQueuePath = "some mq path"; bool useDeadLetterQueue = true; bool useAuthentication = true; bool useEncryption = true; bool recoverable = false; TimeSpan timeToBeReceived = new TimeSpan(123); TimeSpan timeToReachQueue = new TimeSpan(123); MessagePriority messagePriority = MessagePriority.VeryHigh; MessageQueueTransactionType transactionType = MessageQueueTransactionType.Automatic; MsmqTraceListenerData msmqTraceListenerData = new MsmqTraceListenerData(); msmqTraceListenerData.Name = name; msmqTraceListenerData.QueuePath = messageQueuePath; msmqTraceListenerData.MessagePriority = messagePriority; msmqTraceListenerData.TransactionType = transactionType; msmqTraceListenerData.UseEncryption = useEncryption; msmqTraceListenerData.UseAuthentication = useAuthentication; msmqTraceListenerData.UseDeadLetterQueue = useDeadLetterQueue; msmqTraceListenerData.TimeToReachQueue = timeToReachQueue; msmqTraceListenerData.TimeToBeReceived = timeToBeReceived; msmqTraceListenerData.Recoverable = recoverable; MsmqTraceListenerNode msmqTraceListenerNode = new MsmqTraceListenerNode(msmqTraceListenerData); ApplicationNode.AddNode(msmqTraceListenerNode); Assert.AreEqual(name, msmqTraceListenerNode.Name); Assert.AreEqual(messageQueuePath, msmqTraceListenerNode.QueuePath); Assert.AreEqual(transactionType, msmqTraceListenerNode.TransactionType); Assert.AreEqual(messagePriority, msmqTraceListenerNode.MessagePriority); Assert.AreEqual(useDeadLetterQueue, msmqTraceListenerNode.UseDeadLetterQueue); Assert.AreEqual(useAuthentication, msmqTraceListenerNode.UseAuthentication); Assert.AreEqual(useEncryption, msmqTraceListenerNode.UseEncryption); Assert.AreEqual(timeToBeReceived, msmqTraceListenerNode.TimeToBeReceived); Assert.AreEqual(timeToReachQueue, msmqTraceListenerNode.TimeToReachQueue); Assert.AreEqual(recoverable, msmqTraceListenerNode.Recoverable); }
public void WhenCreatingInstanceUsingDefaultContructor_ThenListenerDataTypeIsSet() { var listener = new MsmqTraceListenerData(); Assert.AreEqual(typeof(MsmqTraceListenerData), listener.ListenerDataType); }