示例#1
0
        public void DebugDestinationWriteTest()
        {
            var TNAME = "TestDest-" + MethodBase.GetCurrentMethod().Name;
            var FNAME = TNAME + ".log";

            var fname = Path.Combine(TEST_DIR, FNAME);

            IOMiscUtils.EnsureFileEventuallyDeleted(FNAME);

            using (var svc = new TSLS())
                using (Scope.OnExit(() => File.Delete(fname)))
                {
                    svc.RegisterDestination(
                        new DebugDestination(TNAME)
                    {
                        FileName = FNAME, Path = TEST_DIR
                    });
                    svc.Start();

                    DateTime now = new DateTime(2013, 1, 2, 3, 4, 5);

                    for (var i = 0; i < 10; i++)
                    {
                        svc.Write(new Message {
                            Text = i.ToString(), TimeStamp = now
                        });
                    }

                    svc.WaitForCompleteStop();

                    Aver.IsTrue(File.Exists(fname));
                    string[] lines = File.ReadAllLines(fname);

                    Aver.AreEqual(10, lines.Length);
                    lines.Select((s, i) =>
                    {
                        Aver.AreEqual(
                            "20130102-030405.000000|   {0}||Debug|{1}||0|".Args(Thread.CurrentThread.ManagedThreadId, i),
                            s);
                        return(0);
                    }).ToArray();
                }
        }
示例#2
0
        public void DebugDestinationFilenameDefaultTest()
        {
            string TNAME = "TestDest-" + MethodBase.GetCurrentMethod().Name;
            string FNAME = Path.Combine(TEST_DIR, TNAME + ".log");

            File.Delete(FNAME);

            //var log = new TestMemoryLog();
            //using (var app = new TestApplication { Log = log })
            using (var svc = new TSLS())
                using (Scope.OnExit(() => File.Delete(FNAME)))
                {
                    svc.RegisterDestination(new DebugDestination(TNAME, FNAME));
                    svc.Start();

                    Assert.IsTrue(File.Exists(FNAME));

                    svc.WaitForCompleteStop();
                }
        }
示例#3
0
        public void DebugDestinationFilenameDefaultTest()
        {
            var TNAME = "TestDest-" + MethodBase.GetCurrentMethod().Name;
            var FNAME = Path.Combine(TEST_DIR, TNAME + ".log");

            IOMiscUtils.EnsureFileEventuallyDeleted(FNAME);

            using (var svc = new TSLS())
                using (Scope.OnExit(() => File.Delete(FNAME)))
                {
                    svc.RegisterDestination(new DebugDestination(TNAME)
                    {
                        FileName = FNAME
                    });
                    svc.Start();

                    Aver.IsTrue(File.Exists(FNAME));

                    svc.WaitForCompleteStop();
                }
        }
示例#4
0
        public void DebugDestinationWriteTest()
        {
            string TNAME = "TestDest-" + MethodBase.GetCurrentMethod().Name;
            string FNAME = Path.Combine(TEST_DIR, TNAME + ".log");

            File.Delete(FNAME);

            //var log = new TestMemoryLog();
            //using (var app = new TestApplication { Log = log })
            using (var svc = new TSLS())
                using (Scope.OnExit(() => File.Delete(FNAME)))
                {
                    svc.RegisterDestination(new DebugDestination(TNAME, TNAME + ".log", TEST_DIR));
                    svc.Start();

                    DateTime now = new DateTime(2013, 1, 2, 3, 4, 5);

                    for (var i = 0; i < 10; i++)
                    {
                        svc.Write(new Message {
                            Text = i.ToString(), TimeStamp = now
                        });
                    }

                    svc.WaitForCompleteStop();

                    string[] lines = File.ReadAllLines(FNAME);

                    Assert.AreEqual(10, lines.Length);
                    lines.Select((s, i) =>
                    {
                        Assert.AreEqual(
                            "20130102-030405.000000|   {0}||Debug|{1}||0|".Args(Thread.CurrentThread.ManagedThreadId, i),
                            s);
                        return(0);
                    });
                }
        }
示例#5
0
        public void CSVDestinationDefaultFilenameTest()
        {
            var FNAME = "{0:yyyyMMdd}.log.csv".Args(App.LocalizedTime);

            var fname = Path.Combine(TEST_DIR, FNAME);

            IOMiscUtils.EnsureFileEventuallyDeleted(fname);

            using (var svc = new TSLS())
                using (Scope.OnExit(() => File.Delete(fname)))
                {
                    svc.RegisterDestination(
                        new CSVFileDestination()
                    {
                        Path = TEST_DIR
                    });
                    svc.Start();

                    Aver.IsTrue(File.Exists(fname));

                    svc.WaitForCompleteStop();
                }
        }
示例#6
0
        public void CSVDestinationFilenameDefaultTest()
        {
            string TNAME = "TestDest-" + MethodBase.GetCurrentMethod().Name;
            string FNAME = Path.Combine(TEST_DIR, TNAME + CSVFileDestination.DEFAULT_EXTENSION);

            File.Delete(FNAME);

            //var log = new TestMemoryLog();
            //using (var app = new TestApplication { Log = log })
            using (var svc = new TSLS())
            using (Scope.OnExit(() => File.Delete(FNAME)))
            {
                svc.RegisterDestination(new CSVFileDestination(TNAME, TEST_DIR));
                svc.Start();

                Assert.IsTrue(File.Exists(FNAME));

                svc.WaitForCompleteStop();
            }
        }
示例#7
0
        public void DebugDestinationWriteTest()
        {
            string TNAME = "TestDest-" + MethodBase.GetCurrentMethod().Name;
            string FNAME = Path.Combine(TEST_DIR, TNAME + ".log");

            File.Delete(FNAME);

            //var log = new TestMemoryLog();
            //using (var app = new TestApplication { Log = log })
            using (var svc = new TSLS())
            using (Scope.OnExit(() => File.Delete(FNAME)))
            {
                svc.RegisterDestination(new DebugDestination(TNAME, TNAME + ".log", TEST_DIR));
                svc.Start();

                DateTime now = new DateTime(2013, 1, 2, 3, 4, 5);

                for (var i=0; i < 10; i++)
                    svc.Write(new Message { Text = i.ToString(), TimeStamp = now });

                svc.WaitForCompleteStop();

                string[] lines = File.ReadAllLines(FNAME);

                Assert.AreEqual(10, lines.Length);
                lines.Select((s, i) =>
                {
                    Assert.AreEqual(
                        "20130102-030405.000000|   {0}||Debug|{1}||0|".Args(Thread.CurrentThread.ManagedThreadId, i),
                        s);
                    return 0;
                });
            }
        }