Пример #1
0
        public void TestNullLogger()
        {
            LogDispatcher.LoggerFactory = null;
            var testee = new MyTestComponent();

            testee.DoSomeLogging();
        }
Пример #2
0
        public void TestStreamFile()
        {
            MemoryStream memoryStream = new MemoryStream();

            LogDispatcher.LoggerFactory = new StreamLoggerFactory(memoryStream);
            MyTestComponent test = new MyTestComponent();

            test.DoSomeLogging();
            // Open the file and check what is inside
            byte[] fsContent = new byte[memoryStream.Length];
            memoryStream.Seek(0, SeekOrigin.Begin);
            memoryStream.Read(fsContent, 0, fsContent.Length);
            var fsText = Encoding.UTF8.GetString(fsContent, 0, fsContent.Length);

            Assert.StartsWith("An informative message", fsText);
            Assert.EndsWith("With exception context System.Exception: Something is not supported\r\n", fsText);
        }
Пример #3
0
        public void TestStreamFile()
        {
            MyTestComponent test = new MyTestComponent();

            test.DoSomeLogging();
            // now close the logger
            LogDispatcher.LoggerFactory = null;
            // Open the file and check what is inside
            var fs = new FileStream(logFilePath, FileMode.Open, FileAccess.ReadWrite);

            byte[] fsContent = new byte[fs.Length];
            fs.Read(fsContent, 0, fsContent.Length);
            fs.Dispose();
            var fsText = Encoding.UTF8.GetString(fsContent, 0, fsContent.Length);

            Assert.StartsWith("An informative message", fsText);
            Assert.EndsWith("With exception context System.Exception: Something is not supported", fsText);
        }
Пример #4
0
        public void TestMethodSerialDebug()
        {
            MyTestComponent test = new MyTestComponent();

            test.DoSomeLogging();
        }
Пример #5
0
        public void TestDebugTest()
        {
            MyTestComponent test = new MyTestComponent();

            test.DoSomeLogging();
        }