Пример #1
0
        public void MetaList_Ok()
        {
            using var area = new TestArea("metaListOkTest");
            DroneDB.Init(area.TestFolder);

            DroneDB.MetaAdd(area.TestFolder, "annotations", "123");
            DroneDB.MetaAdd(area.TestFolder, "examples", "abc");
            DroneDB.MetaList(area.TestFolder).Should().HaveCount(2);
        }
Пример #2
0
        public void MetaAdd_Ok()
        {
            using var area = new TestArea("metaAddOkTest");
            DroneDB.Init(area.TestFolder);

            FluentActions.Invoking(() => DroneDB.MetaAdd(area.TestFolder, "test", "123")).Should()
            .Throw <DDBException>();    // Needs plural key
            // DroneDB.MetaAdd("metaAddTest", "", "tests", "123").Data.ToObject<int>().Should().Be(123);
        }
Пример #3
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);
        }
Пример #4
0
        public void MetaAdd_Json()
        {
            using var area = new TestArea("metaAddJsonTest");
            DroneDB.Init(area.TestFolder);

            var res = DroneDB.MetaAdd(area.TestFolder, "tests", "{\"test\": true}");

            JsonConvert.SerializeObject(res.Data).Should().Be("{\"test\":true}");
            res.Id.Should().NotBeNull();
            res.ModifiedTime.Should().BeCloseTo(DateTime.UtcNow, new TimeSpan(0, 0, 1));
        }
Пример #5
0
        public void MetaGet_Ok2()
        {
            using var area = new TestArea("metaGetOkTest");
            DroneDB.Init(area.TestFolder);

            DroneDB.MetaAdd(area.TestFolder, "tests", "{\"test\":true}");
            DroneDB.MetaAdd(area.TestFolder, "tests", "{\"test\":false}");
            DroneDB.MetaAdd(area.TestFolder, "tests", "{\"test\":null}");

            var res = JsonConvert.DeserializeObject <Meta[]>(DroneDB.MetaGet(area.TestFolder, "tests"));

            res.Should().HaveCount(3);
        }
Пример #6
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);
        }
Пример #7
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);
        }
Пример #8
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");
        }