Beispiel #1
0
        public void testAppendLoggingEvent()
        {
            LeTarget l = new LeTarget();

            l.Layout = new SimpleLayout();

            LogEventInfo logEvent = new LogEventInfo();

            logEvent.Message    = "Critical";
            logEvent.LoggerName = "root";
            logEvent.Level      = LogLevel.Debug;
            logEvent.TimeStamp  = DateTime.Now;
            logEvent.Exception  = new Exception();

            l.TestWrite(logEvent);
            Assert.AreEqual(0, l.queue.Count);

            var appSettings = ConfigurationManager.AppSettings;

            appSettings["LOGENTRIES_ACCOUNT_KEY"] = k0;
            appSettings["LOGENTRIES_LOCATION"]    = l0;
            l.TestWrite(logEvent);

            //Message and Exception count as 2 events
            Assert.AreEqual(2, l.queue.Count);

            l.TestClose();
        }
Beispiel #2
0
        public void testCloseTarget()
        {
            LeTarget l           = new LeTarget();
            var      appSettings = ConfigurationManager.AppSettings;

            appSettings["LOGENTRIES_ACCOUNT_KEY"] = k0;
            appSettings["LOGENTRIES_LOCATION"]    = l0;
            l.thread.Start();

            //Wait until thread is active
            for (int i = 0; i < 10; ++i)
            {
                Thread.Sleep(100);
                if (l.thread.IsAlive == true)
                {
                    break;
                }
            }
            Assert.IsTrue(l.thread.IsAlive);

            l.TestClose();

            //Wait until the thread is not active
            for (int i = 0; i < 10; ++i)
            {
                Thread.Sleep(100);
                if (!l.thread.IsAlive)
                {
                    break;
                }
            }
            Assert.IsFalse(l.thread.IsAlive);
        }
Beispiel #3
0
        public void testCheckCredentials()
        {
            LeTarget l           = new LeTarget();
            var      appSettings = ConfigurationManager.AppSettings;

            Assert.IsFalse(l.checkCredentials());

            appSettings["LOGENTRIES_ACCOUNT_KEY"] = "";
            Assert.IsFalse(l.checkCredentials());

            appSettings["LOGENTRIES_LOCATION"] = "";
            Assert.IsFalse(l.checkCredentials());

            appSettings["LOGENTRIES_ACCOUNT_KEY"] = k0;
            Assert.IsFalse(l.checkCredentials());

            appSettings["LOGENTRIES_LOCATION"] = l0;
            Assert.IsTrue(l.checkCredentials());

            //Reset appSettings for following tests
            appSettings["LOGENTRIES_ACCOUNT_KEY"] = "";
            appSettings["LOGENTRIES_LOCATION"]    = "";

            l.TestClose();
        }
Beispiel #4
0
        public void testLeTargetBoolean()
        {
            LeTarget l = new LeTarget();

            Assert.IsFalse(l.Debug);
            Assert.IsFalse(l.Ssl);

            l.TestClose();
        }
Beispiel #5
0
        public void testSetKey()
        {
            LeTarget l = new LeTarget();

            l.Key = k0;
            Assert.AreEqual(k0, l.Key);

            l.Key = k1;
            Assert.AreEqual(k1, l.Key);

            l.TestClose();
        }
Beispiel #6
0
        public void testSetSsl()
        {
            LeTarget l = new LeTarget();

            l.Ssl = true;
            Assert.IsTrue(l.Ssl);

            l.Ssl = false;
            Assert.IsFalse(l.Ssl);

            l.TestClose();
        }
Beispiel #7
0
        public void testSetDebug()
        {
            LeTarget l = new LeTarget();

            l.Debug = true;
            Assert.IsTrue(l.Debug);

            l.Debug = false;
            Assert.IsFalse(l.Debug);

            l.TestClose();
        }
Beispiel #8
0
        public void testSetLocation()
        {
            LeTarget l = new LeTarget();

            l.Location = l0;
            Assert.AreEqual(l0, l.Location);

            l.Location = l1;
            Assert.AreEqual(l1, l.Location);

            l.TestClose();
        }
Beispiel #9
0
        public void testAppendLine()
        {
            LeTarget l = new LeTarget();

            String line0 = "line0";

            l.addLine(line0);
            Assert.AreEqual(1, l.queue.Count);

            for (int i = 0; i < LeTarget.QUEUE_SIZE; ++i)
            {
                l.addLine("line" + i);
            }
            Assert.AreEqual(LeTarget.QUEUE_SIZE, l.queue.Count);

            l.TestClose();
        }