public void BeginOperationTest() { DocumentDataModel target = new DocumentDataModel(); target.New(new Size(700, 1200), new Thickness(32, 32, 32, 32)); DocumentDataModelInvariant(target); Assert.AreEqual(DataModel.ModelState.Ready, target.State); //Test that one call makes the Model busy. target.BeginOperation("testoperation"); Assert.AreEqual(DataModel.ModelState.Busy, target.State); DocumentDataModelInvariant(target); //Test that second call starts a nested operation. target.BeginOperation("nestedTestOperation"); Assert.AreEqual(DataModel.ModelState.Busy, target.State); DocumentDataModelInvariant(target); target.EndOperation("nestedTestOperation"); Assert.AreEqual(DataModel.ModelState.Busy, target.State); DocumentDataModelInvariant(target); target.EndOperation("testoperation"); Assert.AreEqual(DataModel.ModelState.Ready, target.State); DocumentDataModelInvariant(target); }
public void EndOperationTest() { DocumentDataModel target = new DocumentDataModel(); target.New(new Size(700, 1200), new Thickness(32, 32, 32, 32)); DocumentDataModelInvariant(target); Assert.AreEqual(DataModel.ModelState.Ready, target.State); Assert.IsFalse(target.HasUndoData); //Test that undo state is created at end of operation. XElement expected = new XElement(target.DocumentRoot); target.BeginOperation("testoperation"); target.AddShape(new XElement("testelement")); target.EndOperation("testoperation"); Assert.IsTrue(target.HasUndoData); DocumentDataModelInvariant(target); Assert.AreEqual(DataModel.ModelState.Ready, target.State); target.Undo(); //Undo should bring us back before the operation. AssertAreEqualStrings(expected, target.DocumentRoot); }