public void OnApplicationError_WithUnhandledExceptionAndCustomErrorsEnabled_TransfersToErrorPage() { // arrange string transferLocation = null; var server = new Mock <HttpServerUtilityBase>(); server.Setup(s => s.Transfer(It.IsAny <string>())).Callback <string>(s => transferLocation = s); // act SubtextApplication.HandleUnhandledException(new Exception(), server.Object, true /* customErrorEnabled */, new Mock <ILog>().Object); // assert Assert.AreEqual("~/aspx/SystemMessages/error.aspx", transferLocation); }
public void OnApplicationError_WithUnhandledExceptionAndCustomErrorsDisabled_LogsMessage() { // arrange var log = new Mock <ILog>(); string logMessage = null; log.Setup(l => l.Error(It.IsAny <object>(), It.IsAny <Exception>())).Callback <object, Exception>( (s, e) => logMessage = s.ToString()); // act SubtextApplication.HandleUnhandledException(new Exception(), null, false /* customErrorEnabled */, log.Object); // assert Assert.AreEqual("Unhandled Exception trapped in Global.asax", logMessage); }