コード例 #1
0
        public void GetBytesWithKeyRetrievesNullWhenKeyNotExists()
        {
            using (var repo = new DBreezeTestNoSqlRepository("TestRepo", AssureEmptyDir("TestData/DBreezeNoSqlRepository/GetBytesWithKeyRetrievesNullWhenKeyNotExists")))
            {
                var task = repo.GetBytes("testKey");
                task.Wait();

                Assert.Equal(null, task.Result);
            }
        }
コード例 #2
0
        public void GetBytesWithKeyRetrievesBytesForExistingGivenKey()
        {
            var dir = AssureEmptyDir("TestData/DBreezeNoSqlRepository/GetBytesWithKeyRetrievesBytesForExistingGivenKey");

            using (var engine = new DBreezeEngine(dir))
            {
                var transaction = engine.GetTransaction();
                transaction.Insert("TestRepo", "testKey", Encoding.UTF8.GetBytes("keyValueResult"));
                transaction.Commit();
            }

            using (var repo = new DBreezeTestNoSqlRepository("TestRepo", dir))
            {
                var task = repo.GetBytes("testKey");
                task.Wait();

                Assert.Equal("keyValueResult", Encoding.UTF8.GetString(task.Result));
            }
        }