public void GetExceptionHitTreatmentForUnknownError() { // Arrange var exceptionHandler = new ExceptionHandler(); // Act ExceptionHitTreatment result = exceptionHandler.GetExceptionHitTreatment("Error(MY)"); // Assert Assert.AreEqual(ExceptionHitTreatment.BreakNever, result); }
public void GetExceptionHitTreatmentForUnknownErrorAfterChangingDefaults() { // Arrange var exceptionHandler = new ExceptionHandler(); const ExceptionHitTreatment newDefault = ExceptionHitTreatment.BreakAlways; // Act exceptionHandler.SetDefaultExceptionHitTreatment(newDefault); ExceptionHitTreatment result = exceptionHandler.GetExceptionHitTreatment("Error(MY)"); // Assert Assert.AreEqual(newDefault, result); }
public void SetSameExceptionTreatments() { // Arrange var exceptionHandler = new ExceptionHandler(); const string exceptionName = "Error"; const ExceptionHitTreatment newValue = ExceptionHitTreatment.BreakNever; ExceptionHitTreatment initial = exceptionHandler.GetExceptionHitTreatment(exceptionName); // Act bool updated = exceptionHandler.SetExceptionTreatments(new Dictionary<string, ExceptionHitTreatment> { { exceptionName, newValue } }); ExceptionHitTreatment changed = exceptionHandler.GetExceptionHitTreatment(exceptionName); // Assert Assert.AreEqual(ExceptionHitTreatment.BreakNever, initial); Assert.IsFalse(updated); Assert.AreEqual(initial, changed); Assert.AreEqual(newValue, changed); }
public void ClearExceptionTreatments() { // Arrange var exceptionHandler = new ExceptionHandler(); const string exceptionName = "SyntaxError"; exceptionHandler.SetExceptionTreatments(new Dictionary<string, ExceptionHitTreatment> { { exceptionName, ExceptionHitTreatment.BreakAlways } }); ExceptionHitTreatment initial = exceptionHandler.GetExceptionHitTreatment(exceptionName); // Act bool updated = exceptionHandler.ClearExceptionTreatments(new Dictionary<string, ExceptionHitTreatment> { { exceptionName, ExceptionHitTreatment.BreakOnUnhandled } }); ExceptionHitTreatment changed = exceptionHandler.GetExceptionHitTreatment(exceptionName); // Assert Assert.AreEqual(ExceptionHitTreatment.BreakAlways, initial); Assert.IsTrue(updated); Assert.AreEqual(ExceptionHitTreatment.BreakNever, changed); }