示例#1
0
 protected override void Execute()
 {
     foreach (var item in LocalMemoryItems)
     {
         JsonPersistingList.Add(item);
     }
 }
        public void TestStoringAndLoading()
        {
            var list = new JsonPersistingList<IdentifiableForTesting>(editGroup);
            list.Add(new IdentifiableForTesting("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<IdentifiableForTesting>(editGroup);
            list.Add(new IdentifiableForTesting("1"));
            list.Add(new IdentifiableForTesting("2"));
            list.Add(new IdentifiableForTesting("3"));

            var storage = SimpleStorage.EditGroup(editGroup);
            storage.Put("2", "some bad data");

            list = new JsonPersistingList<IdentifiableForTesting>(editGroup);

            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("1", list.First().Id);
            Assert.AreEqual("3", list.Skip(1).First().Id);
        }
        void Run()
        {
            JsonPersistingList = new JsonPersistingList <TestItem>("asdf");
            if (!JsonPersistingList.IsEmpty)
            {
                throw new ArgumentException("List should be empty");
            }
            LocalMemoryItems = CreateTestItems();
            var startTime = DateTime.Now;

            Execute();

            var msNeeded = (DateTime.Now - startTime).TotalMilliseconds;

            label.Text = "needed time (ms) : " + msNeeded;
            JsonPersistingList.Clear();
        }
 protected override void Execute()
 {
     JsonPersistingList.Add(LocalMemoryItems);
 }