示例#1
0
        public void TestOperations()
        {
            var clientId     = Guid.NewGuid();
            var clientId2    = Guid.NewGuid();
            var editorString = new EditorString(clientId);
            var operations1  = editorString.GenerateOperations("abc");


            documentSession.Change(clientId, new DocumenChange
            {
                Operations = operations1
            });
            var state = documentSession.GetState(clientId, null);

            Assert.AreEqual(0, state.Operations.Length);
            Assert.AreEqual(3, state.Revision);

            var state2 = documentSession.GetState(clientId2, null);

            Assert.AreEqual(3, state2.Operations.Length);
            Assert.AreEqual(3, state2.Revision);

            var operations2 = editorString.GenerateOperations("adebc");

            documentSession.Change(clientId, new DocumenChange()
            {
                Operations = operations2
            });
            var state3 = documentSession.GetState(clientId, null);

            Assert.AreEqual(0, state3.Operations.Length);
            Assert.AreEqual(5, state3.Revision);

            var state4 = documentSession.GetState(clientId2, 4);

            Assert.AreEqual(1, state4.Operations.Length);
            Assert.AreEqual(5, state4.Revision);
        }