Exemplo n.º 1
0
        public void SizeRollingTest()
        {
            var v = new MockViewer();
            var l = new MockListener();

            v.LogFile    = Path.Combine(_folder, "logview4net.test.txt");
            v.LogRolling = "100 KB";
            v.LogToFile  = true;
            var s = new Session(l, v);

            s.AddEvent(l, "store log test");

            Assert.IsTrue(File.Exists(v.LogFile), "SizeRollingTest A");
            Assert.IsFalse(File.Exists(v.LogFile + ".1"), "SizeRollingTest B");

            s.AddEvent(l, new String('X', 100 * 1024));

            Assert.IsTrue(File.Exists(v.LogFile), "SizeRollingTest D");
            Assert.IsFalse(File.Exists(v.LogFile + ".1"), "SizeRollingTest E");

            s.AddEvent(l, new String('X', 10 * 1024));

            Assert.IsTrue(File.Exists(v.LogFile), "SizeRollingTest G");
            Assert.IsTrue(File.Exists(v.LogFile + ".1"), "SizeRollingTest H");

            s.AddEvent(l, new String('X', 100 * 1024));
            s.AddEvent(l, new String('X', 10 * 1024));
            Assert.IsTrue(File.Exists(v.LogFile + ".2"), "SizeRollingTest I");
        }
Exemplo n.º 2
0
        public void WriteRollingTest()
        {
            var v = new MockViewer();
            var l = new MockListener();

            v.LogFile    = Path.Combine(_folder, "logview4net.test.txt");
            v.LogRolling = "100 KB";
            v.LogToFile  = true;
            var s = new Session(l, v);

            s.AddEvent(l, "store log test");

            Assert.IsTrue(File.Exists(v.LogFile));
        }
Exemplo n.º 3
0
        public void DateRollingTest()
        {
            var v = new MockViewer();
            var l = new MockListener();

            v.LogFile    = Path.Combine(_folder, "logview4net.test.txt");
            v.LogRolling = "Daily";
            v.LogToFile  = true;
            var s = new Session(l, v);

            s.AddEvent(l, "store log test");

            s._rollingStorage._lastDatePart = "foo";
            s.AddEvent(l, "store log test");
            Assert.IsTrue(File.Exists(v.LogFile + "." + DateTime.Now.ToString("yyyyMMdd")));

            s._rollingStorage._lastDatePart = "foo";
            s.AddEvent(l, "store log test");
            Assert.IsTrue(File.Exists(v.LogFile + "." + DateTime.Now.ToString("yyyyMMdd") + ".1"));
        }