public void HandleViewExceptionCanSwapMessage() { var exceptionHandler = new ViewExceptionHandler(); Exception exception = new Exception("Unhandled exception"); MockErrorVisualizingView mockErrorVisualizingView = new MockErrorVisualizingView(); exceptionHandler.HandleViewException(exception, mockErrorVisualizingView, "Something went wrong"); Assert.AreEqual("Something went wrong", mockErrorVisualizingView.ErrorMessage); MockLogger logger = SharePointServiceLocator.Current.GetInstance <ILogger>() as MockLogger; Assert.AreEqual("Unhandled exception", logger.ErrorMessage); }
public void CanFindIViewErrorMessageInParents() { Control child = new Control(); Control parent = new Control(); MockErrorVisualizingView controlToFind = new MockErrorVisualizingView(); controlToFind.Controls.Add(parent); parent.Controls.Add(child); var foundControl = ViewExceptionHandler.FindErrorVisualizer(child); Assert.AreSame(controlToFind, foundControl); }
public void HandleViewExceptionShouldLogAndShowDefaultExceptionMessage() { var exceptionHandler = new ViewExceptionHandler(); Exception exception = new Exception("Unhandled exception"); MockErrorVisualizingView mockErrorVisualizingView = new MockErrorVisualizingView(); exceptionHandler.HandleViewException(exception, mockErrorVisualizingView); Assert.IsTrue(mockErrorVisualizingView.DefaultErrorMessageShown); MockLogger logger = SharePointServiceLocator.Current.GetInstance <ILogger>() as MockLogger; Assert.AreEqual("Unhandled exception", logger.ErrorMessage); }
public void FindErrorVisualizer_FindsIErrorVisualizerInParents() { // Arrange var child = new Control(); var parent = new Control(); var controlToFind = new MockErrorVisualizingView(); // Act controlToFind.Controls.Add(parent); parent.Controls.Add(child); var foundControl = ViewExceptionHandler.FindErrorVisualizer(child); // Assert Assert.AreSame(controlToFind, foundControl); }
public void HandleViewException_SwapsMessage() { // Arrange var exceptionHandler = new ViewExceptionHandler(); var exception = new Exception("Unhandled exception"); var mockErrorVisualizingView = new MockErrorVisualizingView(); // Act exceptionHandler.HandleViewException(exception, mockErrorVisualizingView, "Something went wrong"); // Assert Assert.AreEqual("Something went wrong", mockErrorVisualizingView.ErrorMessage); MockLogger logger = SharePointServiceLocator.GetCurrent().GetInstance <ILogger>() as MockLogger; Assert.AreEqual("Unhandled exception", logger.ErrorMessage); }