Esempio n. 1
0
        public void LogIfCommentException_DoesNothingForNonCommentException()
        {
            // arrange
            var exception = new Exception();
            var log       = new Mock <ILog>();

            log.Setup(l => l.Info(It.IsAny <string>())).Throws(new Exception("Nothing should have been logged"));

            // act, assert
            SubtextApplication.LogIfCommentException(exception, log.Object);
        }
Esempio n. 2
0
        public void LogIfCommentException_LogsCommentException()
        {
            // arrange
            var    exception  = new CommentDuplicateException();
            var    log        = new Mock <ILog>();
            string logMessage = null;

            log.Setup(l => l.Info(It.IsAny <string>(), exception)).Callback <object, Exception>(
                (o, e) => logMessage = o.ToString());

            // act
            SubtextApplication.LogIfCommentException(exception, log.Object);

            // assert
            Assert.AreEqual("Comment exception thrown and handled in Global.asax.", logMessage);
        }