public void CRUDTests() { var collection = new JsonPersistingList <TestItem>(key) { new TestItem("A"), new TestItem("B"), new TestItem("C"), }; Assert.That(CollectionString, Is.EqualTo("Aa Bb Cc")); collection.Add(new TestItem("D")); Assert.That(CollectionString, Is.EqualTo("Aa Bb Cc Dd")); collection.Insert(2, new TestItem("E")); Assert.That(CollectionString, Is.EqualTo("Aa Bb Ee Cc Dd")); collection.Remove("C"); Assert.That(CollectionString, Is.EqualTo("Aa Bb Ee Dd")); Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Remove("C")); collection.Update(new TestItem("E", "q")); Assert.That(CollectionString, Is.EqualTo("Aa Bb Eq Dd")); collection.Add(new List <TestItem> { new TestItem("X"), new TestItem("Y"), new TestItem("Z") }); Assert.That(CollectionString, Is.EqualTo("Aa Bb Eq Dd Xx Yy Zz")); collection.Add(new TestItem("x"), new TestItem("y"), new TestItem("z")); Assert.That(CollectionString, Is.EqualTo("Aa Bb Eq Dd Xx Yy Zz xx yy zz")); Assert.Throws(typeof(ApplicationException), () => collection.Add(new TestItem("X", "1"), new TestItem("W", "2"))); collection.Clear(); Assert.That(CollectionString, Is.EqualTo("")); }
public void Update(T item) { persistence.Update(item.Id); }