コード例 #1
0
        public void Exception_InnerExceptions_are_included_by_default()
        {
            var ex = new InvalidOperationException("oh noes!", new NullReferenceException("oh my.", new DataException("oops!")));

            Assert.That(ex.ToLogString(),
                        Contains.Substring("NullReferenceException"));
            Assert.That(ex.ToLogString(),
                        Contains.Substring("DataException"));
        }
コード例 #2
0
        public void Exception_Message_is_included_by_default()
        {
            var ex = new InvalidOperationException("oh noes!", new NullReferenceException());

            var msg = ex.ToLogString();

            Assert.That(msg,
                        Contains.Substring("oh noes!"));
        }
コード例 #3
0
        public void TestToLogString()
        {
            Exception testException = new Exception();

            Assert.IsTrue(testException.ToLogString() == "Exception:Exception,Message:Exception of type 'System.Exception' was thrown.", "Empty exception");

            testException = new InvalidOperationException("Don't get drunk!");
            Assert.IsTrue(testException.ToLogString() == "Exception:InvalidOperationException,Message:Don't get drunk!", "Populated extension.");
        }
コード例 #4
0
        public void Exception_Data_is_included_by_default()
        {
            var ex  = new InvalidOperationException("oh noes!", new NullReferenceException());
            var key = "a very important int";

            ex.Data[key] = 123456;

            var msg = ex.ToLogString();

            Assert.That(msg, Contains.Substring(key));
            Assert.That(msg, Contains.Substring("123456"));
        }