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)); }
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); }
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); }