public void EndUndoNotCalledAfterHandledException() { CheckDisposed(); ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); try { using (DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges", true)) { try { throw new Exception(); } catch (Exception) { helper.EndUndoTask = false; throw; // this throws us out of the using statement } } } catch { // just catch the exception so that we can test if undo task was ended } Assert.IsFalse(DummyUndoTaskHelper.m_fUndoTaskEnded); Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackCalled); }
public void NoRollbackAfterNoException() { CheckDisposed(); ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); using (DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { } Assert.IsTrue(DummyUndoTaskHelper.m_fUndoTaskEnded); Assert.IsFalse(DummyUndoTaskHelper.m_fRollbackCalled); }
public void NoRollbackAfterNoException() { ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); using (DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_actionHandler, m_basicView, "kstidUndoStyleChanges")) { // we have to explicitly indicate that the action not be rolled back at the end // of the statements helper.RollBack = false; } Assert.IsFalse(DummyUndoTaskHelper.m_fRollbackAction); Assert.IsFalse(DummyUndoTaskHelper.m_fRollbackCalled); }
public void AutomaticRollbackAfterException() { ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); try { using (DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { throw new Exception(); } } catch { // just catch the exception so that we can test if undo task was ended } Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackAction); Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackCalled); // This re-runs the test to make sure that the undo task was ended properly DummyUndoTaskHelper.m_fRollbackAction = true; DummyUndoTaskHelper.m_fRollbackCalled = false; try { using (DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { throw new Exception(); } } catch { // just catch the exception so that we can test if undo task was ended } Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackAction); Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackCalled); }
public void NoActionsLeftAfterException() { CheckDisposed(); ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); IActionHandler acth = m_basicView.Cache.ActionHandlerAccessor; Assert.AreEqual(0, acth.UndoableActionCount, "Undoable actions after start"); int undoableActionCountInUndoTask = 0; try { using (DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { try { undoableActionCountInUndoTask = acth.UndoableActionCount; throw new Exception(); } catch (Exception) { helper.EndUndoTask = false; throw; // this throws us out of the using statement } } } catch { // just catch the exception so that we can test if undo task was ended } Assert.AreEqual(1, undoableActionCountInUndoTask, "No undoable actions in undo task"); Assert.AreEqual(0, acth.UndoableActionCount, "Undoable actions after getting exception"); }
public void EndUndoNotCalledAfterHandledException() { ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); try { using (DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { throw new Exception(); } } catch { // just catch the exception so that we can test if undo task was ended } Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackAction); Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackCalled); }
public void NoRollbackAfterNoException() { CheckDisposed(); ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); using(DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { } Assert.IsTrue(DummyUndoTaskHelper.m_fUndoTaskEnded); Assert.IsFalse(DummyUndoTaskHelper.m_fRollbackCalled); }
public void NoActionsLeftAfterException() { CheckDisposed(); ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); IActionHandler acth = m_basicView.Cache.ActionHandlerAccessor; Assert.AreEqual(0, acth.UndoableActionCount, "Undoable actions after start"); int undoableActionCountInUndoTask = 0; try { using(DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { try { undoableActionCountInUndoTask = acth.UndoableActionCount; throw new Exception(); } catch(Exception) { helper.EndUndoTask = false; throw; // this throws us out of the using statement } } } catch { // just catch the exception so that we can test if undo task was ended } Assert.AreEqual(1, undoableActionCountInUndoTask, "No undoable actions in undo task"); Assert.AreEqual(0, acth.UndoableActionCount, "Undoable actions after getting exception"); }
public void AutomaticRollbackAfterException() { CheckDisposed(); ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); try { using(DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges", true)) { try { throw new Exception(); } catch(Exception) { helper.EndUndoTask = false; throw; // this throws us out of the using statement } } } catch { // just catch the exception so that we can test if undo task was ended } Assert.IsFalse(DummyUndoTaskHelper.m_fUndoTaskEnded); Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackCalled); // This re-runs the test to make sure that the undo task was ended properly DummyUndoTaskHelper.m_fUndoTaskEnded = false; DummyUndoTaskHelper.m_fRollbackCalled = false; try { using(DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges", true)) { try { throw new Exception(); } catch(Exception) { helper.EndUndoTask = false; throw; // this throws us out of the using statement } } } catch { // just catch the exception so that we can test if undo task was ended } Assert.IsFalse(DummyUndoTaskHelper.m_fUndoTaskEnded); Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackCalled); }
public void EndUndoCalledAfterUnhandledException() { CheckDisposed(); ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); try { using(DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { throw new Exception(); // this throws us out of the using statement } } catch { // just catch the exception so that we can test if undo task was ended } Assert.IsTrue(DummyUndoTaskHelper.m_fUndoTaskEnded); Assert.IsFalse(DummyUndoTaskHelper.m_fRollbackCalled); }
public void NoRollbackAfterNoException() { ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); using(DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_actionHandler, m_basicView, "kstidUndoStyleChanges")) { // we have to explicitly indicate that the action not be rolled back at the end // of the statements helper.RollBack = false; } Assert.IsFalse(DummyUndoTaskHelper.m_fRollbackAction); Assert.IsFalse(DummyUndoTaskHelper.m_fRollbackCalled); }
public void AutomaticRollbackAfterException() { ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); try { using (DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { throw new Exception(); } } catch { // just catch the exception so that we can test if undo task was ended } Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackAction); Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackCalled); // This re-runs the test to make sure that the undo task was ended properly DummyUndoTaskHelper.m_fRollbackAction = true; DummyUndoTaskHelper.m_fRollbackCalled = false; try { using(DummyUndoTaskHelper helper = new DummyUndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { throw new Exception(); } } catch { // just catch the exception so that we can test if undo task was ended } Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackAction); Assert.IsTrue(DummyUndoTaskHelper.m_fRollbackCalled); }