Example #1
0
        public void OperateListCreateContext()
        {
            Key key = new Key(args.ns, args.set, "oplkey20");

            client.Delete(null, key);

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

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

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

            l2.Add(Value.Get(1));
            l2.Add(Value.Get(2));
            l2.Add(Value.Get(3));

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

            l3.Add(Value.Get(6));
            l3.Add(Value.Get(5));
            l3.Add(Value.Get(4));
            l3.Add(Value.Get(1));

            List <Value> inputList = new List <Value>();

            inputList.Add(Value.Get(l1));
            inputList.Add(Value.Get(l2));
            inputList.Add(Value.Get(l3));

            // Create list.
            Record record = client.Operate(null, key,
                                           ListOperation.AppendItems(new ListPolicy(ListOrder.ORDERED, 0), binName, inputList),
                                           Operation.Get(binName)
                                           );

            // Append value to new list created after the original 3 lists.
            record = client.Operate(null, key,
                                    ListOperation.Append(binName, Value.Get(2), CTX.ListIndexCreate(3, ListOrder.ORDERED, false)),
                                    //ListOperation.Create(binName, ListOrder.ORDERED, false, CTX.ListIndex(3)),
                                    //ListOperation.Append(binName, Value.Get(2), CTX.ListIndex(3)),
                                    Operation.Get(binName)
                                    );

            AssertRecordFound(key, record);

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

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

            Assert.AreEqual(1, count);

            IList list = (IList)results[i++];

            Assert.AreEqual(4, list.Count);

            // Test last nested list.
            list = (IList)list[1];
            Assert.AreEqual(1, list.Count);
            Assert.AreEqual(2, (long)list[0]);
        }