public void HandleBadConnectionStringException_IgnoresOtherExceptions() { // arrange var exception = new Exception(); var server = new Mock <HttpServerUtilityBase>(); server.Setup(s => s.Transfer(It.IsAny <string>())).Throws(new Exception("Should not have transfered")); // act bool handled = SubtextApplication.HandleBadConnectionStringException(exception, server.Object); // assert Assert.IsFalse(handled); }
HandleBadConnectionStringException_WithInvalidOperationExceptionContainingOtherMessages_IgnoresException() { // arrange var exception = new InvalidOperationException("Something or other"); var server = new Mock <HttpServerUtilityBase>(); server.Setup(s => s.Transfer(It.IsAny <string>())).Throws(new Exception("Should not have transfered")); // act bool handled = SubtextApplication.HandleBadConnectionStringException(exception, server.Object); // assert Assert.IsFalse(handled); }
HandleBadConnectionStringException_WithArgumentExceptionContainingInvalidValueForKey_TransfersToBadConnectionStringPage () { // arrange var exception = new ArgumentException("Invalid value for key"); var server = new Mock <HttpServerUtilityBase>(); string transferLocation = null; server.Setup(s => s.Transfer(It.IsAny <string>())).Callback <string>(s => transferLocation = s); // act bool handled = SubtextApplication.HandleBadConnectionStringException(exception, server.Object); // assert Assert.IsTrue(handled); Assert.AreEqual("~/aspx/SystemMessages/CheckYourConnectionString.aspx", transferLocation); }
HandleBadConnectionStringException_WithInvalidOperationExceptionMentioningConnectionString_TransfersToBadConnectionStringPage () { // arrange var exception = new InvalidOperationException("No ConnectionString Found"); var server = new Mock <HttpServerUtilityBase>(); string transferLocation = null; server.Setup(s => s.Transfer(It.IsAny <string>())).Callback <string>(s => transferLocation = s); // act bool handled = SubtextApplication.HandleBadConnectionStringException(exception, server.Object); // assert Assert.IsTrue(handled); Assert.AreEqual("~/aspx/SystemMessages/CheckYourConnectionString.aspx", transferLocation); }