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 async Task NormalRead() { _subSecretStore.ReadAsync(ServiceInstanceKey).Returns(SampleUtils.GetSampleContent(ServiceInstanceSampleFile)); LocalObjectStore localObjectStore = CreateLocalObjectStore(); HealthServiceInstance serviceInstance = await localObjectStore.ReadAsync <HealthServiceInstance>(ServiceInstanceKey); Assert.AreEqual("test", serviceInstance.Id); Assert.AreEqual("Test", serviceInstance.Name); Assert.AreEqual("description", serviceInstance.Description); Assert.AreEqual(new Uri("http://contoso.com"), serviceInstance.HealthServiceUrl); Assert.AreEqual(new Uri("http://contoso.com/shell"), serviceInstance.ShellUrl); }
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 async Task NormalWrite() { var serviceInstance = new HealthServiceInstance { Id = "test", Name = "Test", Description = "description", HealthServiceUrl = new Uri("http://contoso.com"), ShellUrl = new Uri("http://contoso.com/shell"), }; LocalObjectStore localObjectStore = CreateLocalObjectStore(); await localObjectStore.WriteAsync(ServiceInstanceKey, serviceInstance); await _subSecretStore.Received().WriteAsync(ServiceInstanceKey, SampleUtils.GetSampleContent(ServiceInstanceSampleFile)); }
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)); }