PersistentList <TestItem> BuildTestList() { var list = new PersistentList <TestItem>(editGroup); list.Add(new TestItem("1")); list.Add(new TestItem("2")); list.Add(new TestItem("3")); return(list); }
PersistentList <IdentifiableForTesting> BuildTestList() { var list = new PersistentList <IdentifiableForTesting>(editGroup); list.Add(new IdentifiableForTesting("1")); list.Add(new IdentifiableForTesting("2")); list.Add(new IdentifiableForTesting("3")); return(list); }
public void TestLoadingInsertedItemFromPersistence() { var list = BuildTestList(); list.Insert(1, new TestItem("x")); list = new PersistentList <TestItem>(editGroup); Assert.That(list.Count, Is.EqualTo(4)); Assert.That(list[1].Id, Is.EqualTo("x")); }
public void TestLoadingOfObjectsFromPersitence() { var list = BuildTestList(); list = new PersistentList <TestItem>(editGroup); var i = 1; foreach (var a in list) { Assert.AreEqual(a.Id, i++.ToString()); } Assert.AreEqual(3, list.Count); }
public void TestIteratingOverListWithBrokenItems() { var list = BuildTestList(); var storage = SimpleStorage.EditGroup(editGroup); storage.Put("2", "break data with id 2"); list = new PersistentList <TestItem>(editGroup); int count = 0; foreach (var a in list) { Assert.AreEqual(a.Id, (++count + (count > 1 ? 1 : 0)).ToString()); } Assert.AreEqual(2, count); Assert.AreEqual(2, list.Count); Assert.IsFalse(storage.HasKey("2"), "The broken object should automatically be removed"); Assert.AreEqual(2, storage.Get <List <string> >("ids").Count, "The internal object index should automatically remove the broken id"); }