Exemplo n.º 1
0
        public void GetFilePathAndDelete()
        {
            using (var store = new ObjectStore(new LocalObjectStore()))
            {
                store.Initialize("test", 0, 0, "", new Controls()
                {
                    PersistenceIntervalSeconds = -1
                });
                Assert.IsTrue(Directory.Exists("./LocalObjectStoreTests/test"));

                var key = "ILove";
                store.SaveString(key, "Pizza");
                var path = store.GetFilePath(key);

                Assert.IsTrue(File.Exists(path));
                store.Delete(key);

                Assert.IsFalse(File.Exists(path));
            }
        }
Exemplo n.º 2
0
        public void AfterDeletingACarFromTheStore_AttemptingToRetrieveItByIdThrowsNotFoundException()
        {
            // Arrange
            var store = new ObjectStore(_rootFileLocation);
            var id    = Guid.NewGuid();
            var book  = new Book
            {
                Id     = id,
                Author = "Harper Lee",
                Title  = "To Kill A Mockingbird",
                ISBN   = "9781784752637"
            };

            _ = store.Put(book);

            // Act
            store.Delete(id);

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { store.Get <Book>(id); });
        }