예제 #1
0
        private bool Flush()
        {
            if (m_historyLogQueue.IsEmpty())
            {
                if (g_traceInfo.IsVerboseEnabled)
                {
                    TraceHelper.TraceVerbose(g_traceInfo, "Queue is empty");
                }

                return(false);
            }

            using (var unitOfWork = UnitOfWork.Begin(m_unitOfWorkName))
            {
                m_historyLogQueue.Process(item => m_historyLogRepository.Add(item));

                unitOfWork.Commit();
            }

            if (g_traceInfo.IsVerboseEnabled)
            {
                TraceHelper.TraceVerbose(g_traceInfo, "Queue flushed");
            }

            return(true);
        }
예제 #2
0
        public void Add(string username, int eventid, string related, string args)
        {
            // Arrange
            Assert.True(m_historyLogQueue.IsEmpty());

            // Act
            m_historyLogAgent.Add(username, (short)eventid, related, HistoryLogItem.Split(args));

            // Assert
            Assert.False(m_historyLogQueue.IsEmpty());
            HistoryLogItem item = null;

            m_historyLogQueue.Process(x => item = x);
            Assert.NotNull(item);

            Assert.Equal(username, item.Username);
            Assert.True(DateTime.UtcNow.Subtract(item.Timestamp) < TimeSpan.FromSeconds(1));
            Assert.Equal(eventid, item.EventId);
            Assert.Equal(1, item.Hosts.Length);
            Assert.Equal(IpNumberHelper.ToIpNumber(RemoteLocation.Localhost.Hosts[0]), item.Hosts[0]);
            Assert.Equal(related, item.RelatedTo);
            Assert.Equal(args, item.Arguments);
        }
예제 #3
0
        public void Enqueue()
        {
            // Arrange
            Assert.True(m_queue.IsEmpty());
            var item = new HistoryLogItem();

            // Act
            m_queue.Enqueue(item);

            // Assert
            Assert.False(m_queue.IsEmpty());
            m_queue.Process(x => Assert.Equal(item, x));
        }