public void ListSimple() { using (var tempFile = new TemporaryFile()) using (var store2 = new ListStore<int>(VirtualFileSystem.OpenStream(tempFile.Path, VirtualFileMode.OpenOrCreate, VirtualFileAccess.ReadWrite, VirtualFileShare.ReadWrite))) using (var store1 = new ListStore<int>(VirtualFileSystem.OpenStream(tempFile.Path, VirtualFileMode.OpenOrCreate, VirtualFileAccess.ReadWrite, VirtualFileShare.ReadWrite))) { store1.UseTransaction = true; // Add a value to store2 and saves it store2.AddValue(1); store2.Save(); // Add a value to store1 without saving store1.AddValue(2); Assert.AreEqual(new[] { 2 }, store1.GetValues()); // Check that store1 contains value from store2 first store1.LoadNewValues(); Assert.AreEqual(new[] { 1, 2 }, store1.GetValues()); // Save and check that results didn't change store1.Save(); Assert.AreEqual(new[] { 1, 2 }, store1.GetValues()); } }
public void ListSimple() { using (var tempFile = new TemporaryFile()) using (var store2 = new ListStore <int>(VirtualFileSystem.OpenStream(tempFile.Path, VirtualFileMode.OpenOrCreate, VirtualFileAccess.ReadWrite, VirtualFileShare.ReadWrite))) using (var store1 = new ListStore <int>(VirtualFileSystem.OpenStream(tempFile.Path, VirtualFileMode.OpenOrCreate, VirtualFileAccess.ReadWrite, VirtualFileShare.ReadWrite))) { store1.UseTransaction = true; // Add a value to store2 and saves it store2.AddValue(1); store2.Save(); // Add a value to store1 without saving store1.AddValue(2); Assert.AreEqual(new[] { 2 }, store1.GetValues()); // Check that store1 contains value from store2 first store1.LoadNewValues(); Assert.AreEqual(new[] { 1, 2 }, store1.GetValues()); // Save and check that results didn't change store1.Save(); Assert.AreEqual(new[] { 1, 2 }, store1.GetValues()); } }