public void Clear_removes_all_entries() { var sut = new FilesystemCache(CACHE_PATH); sut.Add("key1", "1"); sut.Add("key2", "2"); sut.Clear(); Assert.AreEqual(0, Directory.GetFiles(CACHE_PATH).Length); }
public void Adding_existing_key_does_not_overwrite_value() { const string entry_filename = CACHE_PATH + @"\mykey.txt"; File.Delete(entry_filename); var sut = new FilesystemCache(CACHE_PATH); sut.Add("mykey", "hello"); sut.Add("mykey", "world"); Assert.AreEqual("hello", File.ReadAllText(entry_filename)); }
public void Adding_key_creates_file_and_stores_value() { const string entry_filename = CACHE_PATH + @"\mykey.txt"; File.Delete(entry_filename); var sut = new FilesystemCache(CACHE_PATH); sut.Add("mykey", "hello"); Assert.AreEqual("hello", File.ReadAllText(entry_filename)); }
public void Replace_an_existing_value() { const string entry_filename = CACHE_PATH + @"\mykey.txt"; var sut = new FilesystemCache(CACHE_PATH); sut.Add("mykey", "will be overwritten"); sut.ReplaceOrAdd("mykey", "hello"); Assert.AreEqual("hello", File.ReadAllText(entry_filename)); }
public void Remove_a_key() { const string entry_filename = CACHE_PATH + @"\mykey.txt"; var sut = new FilesystemCache(CACHE_PATH); sut.Add("mykey", "to be deleted"); sut.Remove("mykey"); Assert.IsFalse(File.Exists(entry_filename)); }