示例#1
0
        public async Task AddAndRemove()
        {
            LCObject book = new LCObject("Book");

            book["pages"] = new List <int> {
                1, 2, 3, 4, 5
            };
            await book.Save();

            // add
            book.Add("pages", 6);
            await book.Save();

            TestContext.WriteLine(book["pages"]);
            Assert.AreEqual((book["pages"] as List <object>).Count, 6);
            book.AddAll("pages", new List <int> {
                7, 8, 9
            });
            await book.Save();

            TestContext.WriteLine(book["pages"]);
            Assert.AreEqual((book["pages"] as List <object>).Count, 9);

            // remove
            book.Remove("pages", 2);
            TestContext.WriteLine(book["pages"]);
            await book.Save();

            Assert.AreEqual((book["pages"] as List <object>).Count, 8);
            book.RemoveAll("pages", new List <int> {
                1, 2, 3
            });
            await book.Save();

            TestContext.WriteLine(book["pages"]);
            Assert.AreEqual((book["pages"] as List <object>).Count, 6);
        }