Пример #1
0
        public void EncodeAndDecodeArrays()
        {
            Document[] docs = GetDocuments(2);

            Array array1 = docs[0].GetArray("array");
            Array array2 = docs[1].GetArray("array");

            docs[0].Update += (doc, data) =>
            {
                docs[1].ApplyUpdate(data);
            };

            docs[0].Transact((transaction) =>
            {
                array1.Insert(0, new ContentBinary(BitConverter.GetBytes(1)));
                array1.Insert(1, new ContentBinary(BitConverter.GetBytes(3)));
            });

            docs[0].Transact((transaction) =>
            {
                array1.Insert(1, new ContentBinary(BitConverter.GetBytes(2)));
            });

            Assert.Equal(1, BitConverter.ToInt32((array2[0] as ContentBinary).data));
            Assert.Equal(2, BitConverter.ToInt32((array2[1] as ContentBinary).data));
            Assert.Equal(3, BitConverter.ToInt32((array2[2] as ContentBinary).data));
        }
Пример #2
0
        public void CreateArrayDoc()
        {
            Document doc = GetDocuments(1)[0];

            Array array = doc.GetArray("array");

            array.Insert(0, new ContentBinary(BitConverter.GetBytes(1)));
            array.Insert(1, new ContentBinary(BitConverter.GetBytes(3)));
            array.Insert(1, new ContentBinary(BitConverter.GetBytes(2)));

            Assert.Equal(1, BitConverter.ToInt32((array[0] as ContentBinary).data));
            Assert.Equal(2, BitConverter.ToInt32((array[1] as ContentBinary).data));
            Assert.Equal(3, BitConverter.ToInt32((array[2] as ContentBinary).data));
        }