示例#1
0
        public void MetaRemove_Ok()
        {
            using var area = new TestArea("metaRemoveOkTest");
            DroneDB.Init(area.TestFolder);

            var id = DroneDB.MetaSet(area.TestFolder, "test", "123").Id;

            DroneDB.MetaRemove(area.TestFolder, "invalid").Should().Be(0);
            DroneDB.MetaRemove(area.TestFolder, id).Should().Be(1);
            DroneDB.MetaRemove(area.TestFolder, id).Should().Be(0);
        }
示例#2
0
        public void MetaUnset_Ok()
        {
            using var area = new TestArea("metaUnsetOkTest");
            DroneDB.Init(area.TestFolder);

            var f = Path.Join(area.TestFolder, "test.txt");

            File.WriteAllText(f, null);

            DroneDB.Add(area.TestFolder, f);

            DroneDB.MetaSet(area.TestFolder, "abc", "[1,2,3]");
            DroneDB.MetaUnset(area.TestFolder, "abc", f).Should().Be(0);
            DroneDB.MetaUnset(area.TestFolder, "abc").Should().Be(1);
            DroneDB.MetaUnset(area.TestFolder, "abc").Should().Be(0);
        }
示例#3
0
        public void MetaGet_Ok()
        {
            using var area = new TestArea("metaGetOkTest");
            DroneDB.Init(area.TestFolder);

            DroneDB.MetaSet(area.TestFolder, "abc", "true");

            FluentActions.Invoking(() => DroneDB.MetaGet(area.TestFolder, "nonexistant")).Should()
            .Throw <DDBException>();

            FluentActions.Invoking(() => DroneDB.MetaGet(area.TestFolder, "abc", "123")).Should()
            .Throw <DDBException>();

            JsonConvert.DeserializeObject <Meta>(DroneDB.MetaGet(area.TestFolder, "abc")).Data
            .Should().Be(true);
        }
示例#4
0
        public void MetaSet_Ok()
        {
            using var area = new TestArea("metaSetOkTest");
            DroneDB.Init(area.TestFolder);

            var f = Path.Join(area.TestFolder, "test.txt");

            File.WriteAllText(f, null);

            DroneDB.Add(area.TestFolder, f);

            FluentActions.Invoking(() => DroneDB.MetaSet(area.TestFolder, "tests", "123", f)).Should()
            .Throw <DDBException>();    // Needs singular key

            DroneDB.MetaSet(area.TestFolder, "test", "abc", f).Data.Should().Be("abc");
            DroneDB.MetaSet(area.TestFolder, "test", "efg", f).Data.Should().Be("efg");
        }