예제 #1
0
        public void DeleteOperation_CreateInverse_InverseUndoesDelete()
        {
            var state        = new DocumentState(1, "1234");
            var delete       = new DeleteOperation(state, 2);
            var deletedstate = delete.ApplyTransform(state.CurrentState);

            Assert.AreEqual(state.CurrentState, delete.CreateInverse(state).ApplyTransform(deletedstate));
        }
예제 #2
0
        public void OperationTransformer_TransformDeleteDelete_LocalEqualToRemote()
        {
            var state = new DocumentState(1, "123456789");

            var localOperation  = new DeleteOperation(state, 2);
            var remoteOperation = new DeleteOperation(state, 2);

            var transformed = OperationTransformer.Transform(remoteOperation, localOperation);

            var stateStr = state.CurrentState;

            stateStr = localOperation.ApplyTransform(stateStr);
            stateStr = transformed.ApplyTransform(stateStr);

            Assert.AreEqual("12456789", stateStr);
        }
예제 #3
0
        public void OperationTransformer_TransformDeleteInsert_LocalBeforeRemote()
        {
            var localState  = new DocumentState(1, "123456789");
            var remoteState = new DocumentState(1, "123456789");

            var localOperation  = new DeleteOperation(localState, 2);
            var remoteOperation = new InsertOperation(remoteState, 4, 'a');

            var transformed = OperationTransformer.Transform(remoteOperation, localOperation);

            var stateStr = localState.CurrentState;

            stateStr = localOperation.ApplyTransform(stateStr);
            stateStr = transformed.ApplyTransform(stateStr);

            Assert.AreEqual("124a56789", stateStr);
        }