Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 3
0
        public void TestBasicSet()
        {
            var coll   = new ReplicatedReactiveRecordCollection <SpecialRecord>("test");
            var record = coll.CreateRecord();

            record.value = 10;
            coll.Add(record);
            Assert.AreEqual(10, coll[0].value);
            var record2 = record;

            record2.value = 20;
            coll[0]       = record2;
            Assert.AreEqual(20, coll[0].value);
            Assert.AreEqual(10, record.value);
            Assert.AreEqual(record2.id, record.id);
            Assert.AreEqual(record.id, coll[0].id);
            Assert.AreEqual(record2.id, coll[0].id);
            Assert.AreEqual(coll.Count, 1);
            foreach (var rec in coll)
            {
                // Only one!
                Assert.AreEqual(20, record2.value);
            }
        }