public void TestCommutative() { var seq = new KSEQReplicatedList <string>("alice"); seq.Add("test"); Assert.AreEqual(1, seq.Count); var ident = new Ident(1, new[] { new Segment(0, "bob") }); var op1 = new KSEQOperation <string>() { id = ident, op = KSEQOperationTypes.Insert, realTime = DateTime.UtcNow.Ticks, replicaId = "bob", value = "hello" }; var op2 = new KSEQOperation <string>() { id = ident, op = KSEQOperationTypes.Remove, realTime = DateTime.UtcNow.Ticks, replicaId = "bob" }; seq.Apply(op2); Assert.AreEqual(1, seq.Count); seq.Apply(op1); Assert.AreEqual(1, seq.Count); }
public void TestRemoveIdentTwice() { var seq = new KSEQReplicatedList <int>("test"); seq.Add(42); var op1 = seq.lastOp; seq.Add(99); seq.RemoveAt(0); Assert.AreEqual(1, seq.Count); var op2 = new KSEQOperation <int>() { replicaId = "test", id = op1?.id, realTime = DateTime.UtcNow.Ticks, op = KSEQOperationTypes.Remove }; seq.Apply(op2); Assert.AreEqual(1, seq.Count); }
public void TestApplyInsertAlreadyExists() { var seq = new KSEQReplicatedList <int>("test"); seq.Add(42); var op1 = seq.lastOp; Assert.AreEqual(1, seq.Count); Assert.AreEqual(42, seq[0]); var op2 = new KSEQOperation <int>() { id = op1?.id, op = KSEQOperationTypes.Insert, replicaId = "test", realTime = DateTime.UtcNow.Ticks, value = 99 }; seq.Apply(op2); Assert.AreEqual(1, seq.Count); }