public void EntryIsWrittenWhenNoTransaction()
        {
            TimeSpan timeToBeReceived = TimeSpan.FromDays(1);
            TimeSpan timeToReachQueue = TimeSpan.Parse("49710.06:28:15");

            System.Messaging.MessageQueueTransactionType trxType = System.Messaging.MessageQueueTransactionType.None;

            configurationStart.LogToCategoryNamed(CategoryName)
            .WithOptions
            .SetAsDefaultCategory()
            .ToSourceLevels(SourceLevels.All)
            .SendTo
            .Msmq(ListenerName)
            .UseQueue(QueuePath)
            .AsRecoverable()
            .Prioritize(MessagePriority)
            .UseDeadLetterQueue()
            .WithTransactionType(trxType)
            .SetTimeToBeReceived(timeToBeReceived)
            .SetTimeToReachQueue(timeToReachQueue)
            .WithTraceOptions(TraceOptions.None)
            .Filter(SourceLevels.Verbose)
            .FormatWith(new FormatterBuilder()
                        .TextFormatterNamed(FormatterName)
                        .UsingTemplate(Template));

            this.SetConfigurationSource();

            LogWriterFactory factory = new LogWriterFactory((e) => this.ConfigurationSource.GetSection(LoggingSettings.SectionName));

            this.writer = factory.Create();
            Logger.SetLogWriter(this.writer);

            LogEntry entry = LogEntryFactory.GetLogEntry(CategoryName, "Test Message");

            this.writer.Write(entry);

            string entryText = MsmqUtil.GetLogEntryFromQueue();

            Assert.IsTrue(entryText == "<?xml version=\"1.0\"?>\r\n<string>My template</string>");
        }
        public void EntryIsNotWrittenWhenTransactionalQueueAndNoTransaction()
        {
            MsmqUtil.ValidateMsmqIsRunning();
            MsmqUtil.DeletePrivateTestQ();
            MsmqUtil.CreatePrivateTestQ();

            System.Messaging.MessagePriority             messagePriority = System.Messaging.MessagePriority.Lowest;
            System.Messaging.MessageQueueTransactionType trxType         = System.Messaging.MessageQueueTransactionType.Single;
            const string QueuePath = MsmqUtil.MessageQueuePath;

            configurationStart.LogToCategoryNamed(CategoryName)
            .WithOptions
            .SetAsDefaultCategory()
            .ToSourceLevels(SourceLevels.All)
            .SendTo
            .Msmq(ListenerName)
            .UseQueue(QueuePath)
            .AsRecoverable()
            .Prioritize(messagePriority)
            .UseDeadLetterQueue()
            .WithTransactionType(trxType)
            .WithTraceOptions(TraceOptions.None)
            .Filter(SourceLevels.Verbose)
            .FormatWith(new FormatterBuilder()
                        .TextFormatterNamed(FormatterName)
                        .UsingTemplate(Template));

            this.SetConfigurationSource();

            LogWriterFactory factory = new LogWriterFactory((e) => this.ConfigurationSource.GetSection(LoggingSettings.SectionName));

            this.writer = factory.Create();
            Logger.SetLogWriter(this.writer);

            LogEntry entry = LogEntryFactory.GetLogEntry(CategoryName, "Test Message");

            this.writer.Write(entry);

            Assert.IsNull(MsmqUtil.GetLogEntryFromQueue());
        }
        public void EntryIsWrittenWhenMaxMSMQTraceListener()
        {
            MsmqUtil.ValidateMsmqIsRunning();
            MsmqUtil.DeletePrivateTestQ();
            MsmqUtil.CreatePrivateTestQ();

            LogWriterFactory factory = new LogWriterFactory((e) => this.ConfigurationSource.GetSection("loggingConfiguration63"));

            this.writer = factory.Create();
            Logger.SetLogWriter(this.writer);

            var entry = LogEntryFactory.GetLogEntry();

            entry.Categories.Add("General");

            this.writer.Write(entry);
            this.writer.Dispose();

            string entryText = MsmqUtil.GetLogEntryFromQueue();

            Assert.IsTrue(entryText.Contains(entry.Message));
        }