public void LoggerManager_PublishEntries()
        {
            var manager       = new MockLogManager();
            var filteredQueue = new MemoryQueue();

            filteredQueue.Enqueue(new LogEntry
            {
                Title    = "test",
                EventId  = 1,
                Priority = 1,
                Severity = TraceEventType.Error,
                Message  = "testing"
            });
            filteredQueue.Enqueue(new LogEntry
            {
                Title    = "test",
                EventId  = 1,
                Priority = 1,
                Severity = TraceEventType.Error,
                Message  = "testing"
            });
            manager.FilteredQueue = filteredQueue;
            manager.PublishFilteredEntries();
            Assert.AreEqual(0, manager.FilteredQueue.Count, "Expected zero enteries in the filtered queue");
        }
        public void LoggerManager_UnfilteredQueue_SetTwice()
        {
            var manager = new MockLogManager();

            manager.UnfilteredQueue = new MockQueue();
            manager.UnfilteredQueue = new MockQueue();
        }
        public void LoggerManager_Write_ValidLogEntry()
        {
            var expected = new LogEntry
            {
                Title    = "test",
                EventId  = 1,
                Priority = 1,
                Severity = TraceEventType.Error,
                Message  = "testing"
            };
            var manager = new MockLogManager {
                UnfilteredQueue = new MockQueue()
            };

            LoggerManager.Start(manager, new Uri("http://test"));

            Assert.IsNotNull(manager);
            ((ILoggerManager)manager).Write(expected);

            Assert.IsNotNull(manager.UnfilteredQueue);
            Assert.AreEqual(1, manager.UnfilteredQueue.Count);
            var actual = manager.UnfilteredQueue.Peek();

            Assert.AreEqual(expected, actual);
        }
        public void FilterEntryTest_FilterEntries()
        {
            var expected = new LogEntry
            {
                Title    = "test",
                EventId  = 1,
                Priority = 1,
                Severity = TraceEventType.Error,
                Message  = "testing"
            };

            var manager = new MockLogManager();

            manager.UnfilteredQueue = new MockQueue();
            manager.FilteredQueue   = new MockQueue();
            LoggerManager.Start(manager, new Uri("http://test"));
            Assert.IsNotNull(manager);
            Assert.IsNotNull(manager.UnfilteredQueue);
            Assert.IsNotNull(manager.FilteredQueue);

            ((ILoggerManager)manager).Write(expected);

            Assert.IsTrue(manager.FilterCalled, "FilterEntries was not called.");

            var actual = manager.FilteredQueue.Peek();

            Assert.AreEqual(expected, actual);
        }
        public void LoggerManager_UnfilteredQueue_SetOnceThenNull()
        {
            var manager = new MockLogManager();

            manager.UnfilteredQueue = new MockQueue();
            manager.UnfilteredQueue = null;
        }
        public void LoggerManager_FilterEntries_ZeroEntries()
        {
            var manager = new MockLogManager();

            manager.UnfilteredQueue = new MockQueue();
            manager.FilteredQueue   = new MockQueue();

            manager.ExecuteFilter();
            Assert.IsTrue(manager.FilterCalled, "Filter was not called.");
        }
        public void LoggerManager_FilterEntries_ThreeEntries()
        {
            var manager = new MockLogManager();

            manager.ExecutePublishFilter = false;
            var unfilteredQueue = new MemoryQueue();

            unfilteredQueue.Enqueue(new LogEntry
            {
                Title    = "test",
                EventId  = 1,
                Priority = 1,
                Severity = TraceEventType.Error,
                Message  = "testing"
            });
            unfilteredQueue.Enqueue(new LogEntry
            {
                Title    = "test",
                EventId  = 1,
                Priority = 1,
                Severity = TraceEventType.Error,
                Message  = "testing"
            });
            unfilteredQueue.Enqueue(new LogEntry
            {
                Title    = "test",
                EventId  = 1,
                Priority = 1,
                Severity = TraceEventType.Error,
                Message  = "testing"
            });

            manager.UnfilteredQueue = unfilteredQueue;
            var filteredQueue = new MemoryQueue();

            manager.FilteredQueue = filteredQueue;
            manager.Initialize(new Uri("http://test"));
            manager.ExecuteFilter();
            Assert.IsTrue(manager.FilterCalled, "Filter was not called.");
            Assert.AreEqual(3, manager.FilteredQueue.Count, "Filters were not executed correctly.");
        }