Exemplo n.º 1
0
        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"));
            }
        }
Exemplo n.º 2
0
        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));
        }