Пример #1
0
        public void TestForeignSetNotInOrder()
        {
            var coll    = new ReplicatedReactiveRecordCollection <SpecialRecord>("local");
            var ops     = new List <KSEQOperation <SpecialRecord> >();
            var record1 = coll.CreateRecord();

            record1.value = 10;
            coll.Add(record1);
            ops.Add(coll.lastOp.Value);
            var record2 = coll.CreateRecord();

            record2.value = 20;
            coll.Add(record2);
            ops.Add(coll.lastOp.Value);
            var record3 = record1;

            record3.value = 30;
            coll[0]       = record3;
            ops.Add(coll.lastOp.Value);

            var coll2 = new ReplicatedReactiveRecordCollection <SpecialRecord>("foreign");

            // Apply set first
            coll2.Apply(ops[2]);
            coll2.Apply(ops[1]);
            coll2.Apply(ops[0]);

            Assert.IsTrue(coll.SequenceEqual(coll2));
        }
Пример #2
0
        public void TestReplaceOtherReplicaRecord()
        {
            var coll1 = new ReplicatedReactiveRecordCollection <SpecialRecord>("local");
            var coll2 = new ReplicatedReactiveRecordCollection <SpecialRecord>("foreign");
            var rec1  = coll1.CreateRecord();

            rec1.value = 10;
            coll1.Add(rec1);
            var op1 = coll1.lastOp.Value;

            coll2.Apply(op1);
            var rec2 = coll2[0];

            rec2.value = 20;
            coll2.Replace(rec2);
            var op2 = coll2.lastOp.Value;

            coll1.Apply(op2);
            Assert.IsTrue(coll1.SequenceEqual(coll2));
        }