コード例 #1
0
        public void WarnWritesAppropriateString()
        {
            var logger = new TraceLogger("loggerName");
            logger.Warn("this is a {0} message", "test");

            Assert.AreEqual(1, this.listener.messages.Count);
            var message = this.listener.messages[0];

            Assert.That(message, Contains.Substring("WARN")); // Log level
            Assert.That(message, Contains.Substring("Stylet")); // Category
            Assert.That(message, Contains.Substring("loggerName")); // Name
            Assert.That(message, Contains.Substring("this is a test message")); // Actual message
        }
コード例 #2
0
        public void ErrorWithMessageWritesAppropriateString()
        {
            var logger = new TraceLogger("loggerWithErrorName");
            var e = new Exception("exception message");
            logger.Error(e, "accompanying message");

            Assert.AreEqual(1, this.listener.messages.Count);
            var message = this.listener.messages[0];

            Assert.That(message, Contains.Substring("ERROR")); // Log level
            Assert.That(message, Contains.Substring("Stylet")); // Category
            Assert.That(message, Contains.Substring("loggerWithErrorName")); // Name
            Assert.That(message, Contains.Substring("exception message")); // Exception message
            Assert.That(message, Contains.Substring("accompanying message"));
        }