Beispiel #1
0
        public void TestHabaneroArgumentException()
        {
            var inner = new UserException();

            var hae = new HabaneroArgumentException("param");
            Assert.AreEqual("The argument 'param' is not valid. ", hae.Message);
            hae = new HabaneroArgumentException("param", "message");
            Assert.AreEqual("The argument 'param' is not valid. message", hae.Message);
            hae = new HabaneroArgumentException("param", "message", inner);
            Assert.AreEqual("The argument 'param' is not valid. message", hae.Message);
            Assert.AreEqual(inner, hae.InnerException);
            hae = new HabaneroArgumentException("param", inner);
            Assert.AreEqual("The argument 'param' is not valid. ", hae.Message);
            Assert.AreEqual(inner, hae.InnerException);
            hae = new HabaneroArgumentException();
            Assert.AreEqual("Exception of type 'Habanero.Base.Exceptions.HabaneroArgumentException' was thrown.", hae.Message);
        }
 public void Test_Log_WithUserException_ShouldLog_Info()
 {
     //---------------Set up test pack-------------------
     var log = GetMockLog();
     IHabaneroLogger logger = new Log4NetLoggerSpy(log);
     var exception = new UserException();
     //---------------Assert Precondition----------------
     log.AssertWasNotCalled(log1 => log1.Info("", exception));
     Assert.IsInstanceOf<UserException>(exception);
     //---------------Execute Test ----------------------
     logger.Log(exception);
     //---------------Test Result -----------------------
     log.AssertWasCalled(log1 => log1.Info("", exception));
     log.AssertWasNotCalled(log1 => log1.Error("", exception));
 }