public void TestStoringAndLoading()
        {
            var list = new JsonPersistingList <TestItem>(key);

            list.Add(new TestItem("A"));
            Assert.True(SimpleStorage.EditGroup(key).HasKey("A"));
            Assert.AreEqual("{\"Id\":\"A\",\"Value\":\"a\"}", SimpleStorage.EditGroup(key).Get("A"));

            list = new JsonPersistingList <TestItem>(key);
            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("A", list.First().Id);
        }
示例#2
0
        public void TestStoringAndLoading()
        {
            var list = new JsonPersistingList <IdentifiableForTesting>(editGroup);

            list.Add(new IdentifiableForTesting("test"));
            Assert.True(SimpleStorage.EditGroup(editGroup).HasKey("test"));
            Assert.AreEqual("{\"Id\":\"test\"}", SimpleStorage.EditGroup(editGroup).Get("test"));

            list = new JsonPersistingList <IdentifiableForTesting>(editGroup);
            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("test", list.First().Id);
        }
        public void TestSkippingNonDeserializableEntries()
        {
            var list = new JsonPersistingList <TestItem>(key);

            list.Add(new TestItem("1"));
            list.Add(new TestItem("2"));
            list.Add(new TestItem("3"));

            var storage = SimpleStorage.EditGroup(key);

            storage.Put("2", "some bad data");

            list = new JsonPersistingList <TestItem>(key);

            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("1", list.First().Id);
            Assert.AreEqual("3", list.Skip(1).First().Id);
        }