コード例 #1
0
        public void TestInfoForLoggable()
        {
            TestTarget.Current.Reset();

            // run...
            var loggable = new TestLoggable();
            loggable.LogInfo("Hello, world.");

            // check...
            Assert.AreEqual(1, TestTarget.Current.NumWritten);
            Assert.AreEqual(LogLevel.Info, TestTarget.Current.LastWritten.Level);
            Assert.IsNull(TestTarget.Current.LastWritten.Exception);
        }
コード例 #2
0
        public void TestInfoForLoggableWithFormat()
        {
            TestTarget.Current.Reset();

            // run...
            var loggable = new TestLoggable();
            loggable.LogInfo("Hello, {0}.", "**foo**");

            // check...
            Assert.AreEqual(1, TestTarget.Current.NumWritten);
            Assert.AreEqual(LogLevel.Info, TestTarget.Current.LastWritten.Level);
            Assert.IsNull(TestTarget.Current.LastWritten.Exception);
            Assert.AreNotEqual(-1, TestTarget.Current.LastWritten.Message.IndexOf("**foo**"));
        }
コード例 #3
0
        public void TestInfoForLoggableWithException()
        {
            TestTarget.Current.Reset();

            // run...
            var loggable = new TestLoggable();
            loggable.LogInfo("Hello, world", new InvalidOperationException("Foobar"));

            // check...
            Assert.AreEqual(1, TestTarget.Current.NumWritten);
            Assert.AreEqual(LogLevel.Info, TestTarget.Current.LastWritten.Level);
            Assert.IsNotNull(TestTarget.Current.LastWritten.Exception);
        }