Exemplo n.º 1
0
        public void BasicPropertyChangeIsRecordedWithFiltering()
        {
            var initialBool = _recordedModel.IsTrue;
            var initialText = "";

            _recordedModel.SubClassB.Text = initialText;
            var initialNumber = _recordedModel.Number;

            _modelRecorder.Record(_undoRedoService, _recordedModel);

            _recordedModel.IsTrue = !_recordedModel.IsTrue;
            _recordedModel.Number++;
            _recordedModel.IsTrue          = !_recordedModel.IsTrue;
            _recordedModel.SubClassB.Text += "ABC";

            _recordedModel.IsTrue = !_recordedModel.IsTrue;
            _recordedModel.Number++;
            _recordedModel.SubClassB.Text += "ABC";

            _recordedModel.Number++;
            _recordedModel.IsTrue = !_recordedModel.IsTrue;
            _recordedModel.Number++;
            _recordedModel.IsTrue = !_recordedModel.IsTrue;

            _recordedModel.IsTrue = !initialBool;

            _recordedModel.SubClassB.Text += "ABC";

            Assert.AreEqual(0, _modelRecorder.UndoRedoService.NbUndo);
            Assert.AreEqual(0, _modelRecorder.UndoRedoService.NbRedo);

            Wait(2000);

            Assert.AreEqual(3, _modelRecorder.UndoRedoService.NbUndo);
            Assert.AreEqual(0, _modelRecorder.UndoRedoService.NbRedo);

            _undoRedoService.Undo();
            Assert.AreEqual(2, _modelRecorder.UndoRedoService.NbUndo);
            Assert.AreEqual(1, _modelRecorder.UndoRedoService.NbRedo);

            _undoRedoService.Undo();
            Assert.AreEqual(1, _modelRecorder.UndoRedoService.NbUndo);
            Assert.AreEqual(2, _modelRecorder.UndoRedoService.NbRedo);

            _undoRedoService.Undo();
            Assert.AreEqual(0, _modelRecorder.UndoRedoService.NbUndo);
            Assert.AreEqual(3, _modelRecorder.UndoRedoService.NbRedo);

            Assert.AreEqual(initialBool, _recordedModel.IsTrue);
            Assert.AreEqual(initialText, _recordedModel.SubClassB.Text);
            Assert.AreEqual(initialNumber, _recordedModel.Number);
        }
Exemplo n.º 2
0
        public void UndoRedoServicePropertyIsTheOneGivenAtRecord()
        {
            Assert.IsNull(_modelRecorder.UndoRedoService);
            _modelRecorder.Record(_undoRedoService, new object());

            Assert.IsNotNull(_modelRecorder.UndoRedoService);
            Assert.AreSame(_undoRedoService, _modelRecorder.UndoRedoService);
        }