public void Test_ExceptionDetailToString_ShouldConcatExceptionMessageAndFurtherMessage() { //---------------Set up test pack------------------- Exception exception = new Exception(GetRandomString()); string furtherMessage = TestUtil.GetRandomString(); RecordingExceptionNotifier.ExceptionDetail exceptionDetail = new RecordingExceptionNotifier.ExceptionDetail(exception, furtherMessage, GetRandomString()); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var toString = exceptionDetail.ToString(); //---------------Test Result ----------------------- Assert.AreEqual(exception.Message + " - " + furtherMessage, toString); }
public void Test_Notify_ShouldIncludeDetailsInExceptions() { //---------------Set up test pack------------------- Exception exception = new Exception(); string furtherMessage = TestUtil.GetRandomString(); string title = TestUtil.GetRandomString(); RecordingExceptionNotifier exceptionNotifier = new RecordingExceptionNotifier(); //---------------Assert Precondition---------------- Assert.AreEqual(0, exceptionNotifier.Exceptions.Count); //---------------Execute Test ---------------------- exceptionNotifier.Notify(exception, furtherMessage, title); //---------------Test Result ----------------------- Assert.AreEqual(1, exceptionNotifier.Exceptions.Count); RecordingExceptionNotifier.ExceptionDetail exceptionDetail = exceptionNotifier.Exceptions[0]; Assert.AreSame(exception, exceptionDetail.Exception); Assert.AreSame(furtherMessage, exceptionDetail.FurtherMessage); Assert.AreSame(title, exceptionDetail.Title); }