public static long GetSizeAfter(int kvps, Action <IDatabase <string, string>, int> action) { using (var ms = new MemoryStream()) using (var db = StringDatabase.Create(ms)) { action(db, kvps); return(ms.Length); } }
public void CreateWithStreamAndVersion(StringDBVersion version) { using (var db = StringDatabase.Create(new MemoryStream(), version, false)) { Insert(db); db.Should() .BeOfType <TransformDatabase <byte[], byte[], string, string> >(); } }
public void CreateWithStream() { using (var db = StringDatabase.Create(new MemoryStream())) { Insert(db); db.Should() .BeOfType <TransformDatabase <byte[], byte[], string, string> >(); } }
public void Create() { using (var db = StringDatabase.Create()) { Insert(db); db.Should() .BeOfType <MemoryDatabase <string, string> >(); } }
public void CreateWithStreamAndVersion(StringDBVersions version) { using (var db = StringDatabase.Create(new MemoryStream(), version, false)) { db.Insert("init", "Hello, World!"); db.Get("init").Should().Be("Hello, World!"); db.Should() .BeOfType <TransformDatabase <byte[], byte[], string, string> >(); } }
public void Create() { using (var db = StringDatabase.Create()) { db.Insert("init", "Hello, World!"); db.Get("init").Should().Be("Hello, World!"); db.Should() .BeOfType <MemoryDatabase <string, string> >(); } }
public static long GetSizeAfter(int times, Action <IDatabase <string, string> > action) { using (var ms = new MemoryStream()) using (var db = StringDatabase.Create(ms)) { for (var i = 0; i < times; i++) { action(db); } return(ms.Length); } }
private static void Main() { // this is the most simplest way to use StringDB // this creates a database in RAM using (var db = StringDatabase.Create()) { // we can insert stuff db.Insert("key", "Hello, World!"); // get that value var value = db.Get("key"); // write it to the console Console.WriteLine(value); } }
public IntegrationTests() { _ms = new MemoryStream(); _openDb = () => { _ms.Position = 0; return(StringDatabase.Create(_ms, true)); }; _insert = db => { db.Insert("a", "d"); db.Insert("b", "e"); db.Insert("c", "f"); }; }
public void IntegrationTest() { if (File.Exists("stringdb.db")) { File.Delete("stringdb.db"); } using (var db = StringDatabase.Create(File.Open("stringdb.db", FileMode.OpenOrCreate))) { db.Insert("test", "value"); db.Insert("test", "value2"); db.Insert("test", "value3"); db.EnumerateAggressively(3) .Should().BeEquivalentTo(new[] { new KeyValuePair <string, string>("test", "value"), new KeyValuePair <string, string>("test", "value2"), new KeyValuePair <string, string>("test", "value3"), }); } using (var db = StringDatabase.Create(File.Open("stringdb.db", FileMode.OpenOrCreate))) { db.Insert("test", "value4"); db.EnumerateAggressively(3) .Should().BeEquivalentTo(new[] { new KeyValuePair <string, string>("test", "value"), new KeyValuePair <string, string>("test", "value2"), new KeyValuePair <string, string>("test", "value3"), new KeyValuePair <string, string>("test", "value4") }); } }