Пример #1
0
        public void OperateNestedListMap()
        {
            Key key = new Key(args.ns, args.set, "oplkey19");

            client.Delete(null, key);

            IList <Value> l11 = new List <Value>();

            l11.Add(Value.Get(7));
            l11.Add(Value.Get(9));
            l11.Add(Value.Get(5));

            IList <Value> l12 = new List <Value>();

            l12.Add(Value.Get(13));

            IList <Value> l1 = new List <Value>();

            l1.Add(Value.Get(l11));
            l1.Add(Value.Get(l12));

            IList <Value> l21 = new List <Value>();

            l21.Add(Value.Get(9));

            IList <Value> l22 = new List <Value>();

            l22.Add(Value.Get(2));
            l22.Add(Value.Get(4));

            IList <Value> l23 = new List <Value>();

            l23.Add(Value.Get(6));
            l23.Add(Value.Get(1));
            l23.Add(Value.Get(9));

            IList <Value> l2 = new List <Value>();

            l2.Add(Value.Get(l21));
            l2.Add(Value.Get(l22));
            l2.Add(Value.Get(l23));

            Dictionary <Value, Value> inputMap = new Dictionary <Value, Value>();

            inputMap[Value.Get("key1")] = Value.Get(l1);
            inputMap[Value.Get("key2")] = Value.Get(l2);

            // Create list.
            client.Put(null, key, new Bin(binName, inputMap));

            // Append value to last list and retrieve map.
            Record record = client.Operate(null, key,
                                           ListOperation.Append(binName, Value.Get(11), CTX.MapKey(Value.Get("key2")), CTX.ListRank(0)),
                                           Operation.Get(binName)
                                           );

            AssertRecordFound(key, record);

            IList results = record.GetList(binName);
            int   i       = 0;

            long count = (long)results[i++];

            Assert.AreEqual(3, count);

            IDictionary map = (IDictionary)results[i++];

            Assert.AreEqual(2, map.Count);

            // Test affected nested list.
            IList list = (IList)map["key2"];

            Assert.AreEqual(3, list.Count);

            list = (IList)list[1];
            Assert.AreEqual(3, list.Count);
            Assert.AreEqual(2, (long)(long?)list[0]);
            Assert.AreEqual(4, (long)(long?)list[1]);
            Assert.AreEqual(11, (long)(long?)list[2]);
        }