Exemplo n.º 1
0
        public void OperateMapRemove()
        {
            // Test remove.
            if (!args.ValidateMap())
            {
                return;
            }

            Key key = new Key(args.ns, args.set, "opmkey7");

            client.Delete(null, key);

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

            inputMap[Value.Get("Charlie")] = Value.Get(55);
            inputMap[Value.Get("Jim")]     = Value.Get(98);
            inputMap[Value.Get("John")]    = Value.Get(76);
            inputMap[Value.Get("Harry")]   = Value.Get(82);
            inputMap[Value.Get("Sally")]   = Value.Get(79);
            inputMap[Value.Get("Lenny")]   = Value.Get(84);
            inputMap[Value.Get("Abe")]     = Value.Get(88);

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

            removeItems.Add(Value.Get("Sally"));
            removeItems.Add(Value.Get("UNKNOWN"));
            removeItems.Add(Value.Get("Lenny"));

            Record record = client.Operate(null, key,
                                           MapOperation.PutItems(MapPolicy.Default, binName, inputMap),
                                           MapOperation.RemoveByKey(binName, Value.Get("NOTFOUND"), MapReturnType.VALUE),
                                           MapOperation.RemoveByKey(binName, Value.Get("Jim"), MapReturnType.VALUE),
                                           MapOperation.RemoveByKeyList(binName, removeItems, MapReturnType.COUNT),
                                           MapOperation.RemoveByValue(binName, Value.Get(55), MapReturnType.KEY),
                                           MapOperation.Size(binName));

            AssertRecordFound(key, record);

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

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

            Assert.AreEqual(7, val);

            object obj = results[i++];

            Assert.IsNull(obj);

            val = (long)results[i++];
            Assert.AreEqual(98, val);

            val = (long)results[i++];
            Assert.AreEqual(2, val);

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

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("Charlie", (string)list[0]);

            val = (long)results[i++];
            Assert.AreEqual(3, val);
        }