public void Setup() { Config.Set("object-store-root", TestStorageRoot); _store = new LocalObjectStore(); _store.Initialize("CSharp-TestAlgorithm", 0, 0, "", new Controls()); }
public void DeletedObjectIsNotReloaded() { using (var store = new LocalObjectStore()) { store.Initialize("test", 0, 0, "", new Controls()); Assert.IsTrue(Directory.Exists("./LocalObjectStoreTests/test")); var validData = new byte[1024 * 4]; store.SaveBytes("a.txt", validData); Assert.IsTrue(store.ContainsKey("a.txt")); store.SaveBytes("b.txt", validData); Assert.IsTrue(store.ContainsKey("b.txt")); // Assert the store has our two objects var storedObj = store.GetEnumerator().AsEnumerable().ToList(); Assert.IsTrue(storedObj.Count == 2); // Delete a.txt and close this store down store.Delete("a.txt"); Assert.IsFalse(store.ContainsKey("a.txt")); } using (var store = new LocalObjectStore()) { // Check that the dir still exists, it had files so it shouldn't have deleted Assert.IsTrue(Directory.Exists("./LocalObjectStoreTests/test")); store.Initialize("test", 0, 0, "", new Controls()); // Check our files; a should be gone, b should be there Assert.IsFalse(store.ContainsKey("a.txt")); Assert.IsTrue(store.ContainsKey("b.txt")); } }
public void DisposeRemovesEmptyStorageFolder() { using (var store = new LocalObjectStore()) { store.Initialize("unused", 0, 0, "", new Controls()); Assert.IsTrue(Directory.Exists("./LocalObjectStoreTests/unused")); } Assert.IsFalse(Directory.Exists("./LocalObjectStoreTests/unused")); }
public void DisposeDoesNotErrorWhenStorageFolderAlreadyDeleted() { var testHandler = new QueueLogHandler(); Log.LogHandler = testHandler; using (var store = new LocalObjectStore()) { store.Initialize("unused", 0, 0, "", new Controls()); Directory.Delete("./LocalObjectStoreTests/unused"); } Assert.IsFalse(testHandler.Logs.Any(message => message.Message.Contains("Error deleting storage directory."))); }
public void DisposeDoesNotDeleteStoreFiles() { string path; using (var store = new LocalObjectStore()) { store.Initialize("test", 0, 0, "", new Controls() { PersistenceIntervalSeconds = -1 }); Assert.IsTrue(Directory.Exists("./LocalObjectStoreTests/test")); var validData = new byte[1024 * 1024 * 4]; var saved = store.SaveBytes("a.txt", validData); Assert.IsTrue(saved); path = store.GetFilePath("a.txt"); Assert.IsTrue(File.Exists(path)); } // Check that it still exists Assert.IsTrue(File.Exists(path)); }