コード例 #1
0
        public void Info_ImageFile_Details()
        {
            //var expectedMeta = JsonConvert.DeserializeObject<Dictionary<string, string>>(
            //    @"{""cameraPitch"":""-89.9000015258789"",""cameraRoll"":""0.0"",""cameraYaw"":""43.79999923706055"",""captureTime"":""1466699554000.0"",""focalLength"":""3.4222222222222225"",""focalLength35"":""20.0"",""height"":""2250"",""make"":""DJI"",""model"":""FC300S"",""orientation"":""1"",""sensor"":""dji fc300s"",""sensorHeight"":""3.4650000000000003"",""sensorWidth"":""6.16"",""width"":""4000""}");

            using var tempFile = new TempFile(TestFileUrl, BaseTestFolder);

            var res = DroneDB.Info(tempFile.FilePath, withHash: true);

            res.Should().NotBeNull();
            res.Should().HaveCount(1);

            var info = res.First();

            // Just check some fields
            //info.Meta.Should().BeEquivalentTo(expectedMeta);

            info.Properties.Should().NotBeEmpty();
            info.Properties.Should().HaveCount(14);
            info.Properties["make"].Should().Be("DJI");
            info.Properties["model"].Should().Be("FC300S");
            info.Properties["sensor"].Should().Be("dji fc300s");
            info.Hash.Should().Be("246fed68dec31b17dc6d885cee10a2c08f2f1c68901a8efa132c60bdb770e5ff");
            info.Type.Should().Be(EntryType.GeoImage);
            info.Size.Should().Be(3876862);
            // We can ignore this
            // info.Depth.Should().Be(0);
            info.PointGeometry.Should().NotBeNull();
            info.PolygonGeometry.Should().NotBeNull();
        }
コード例 #2
0
        public void Tag_ErrorCases_Ok()
        {
            const string badTag  = "pippo";
            const string badTag2 = "����+���+�AAadff_-.-.,";

            using var test = new TestFS(Test3ArchiveUrl, BaseTestFolder);

            var ddbPath = Path.Combine(test.TestFolder, DdbFolder);

            Action act = () => DroneDB.SetTag(ddbPath, badTag);

            act.Should().Throw <DDBException>();

            act = () => DroneDB.SetTag(ddbPath, badTag2);

            act.Should().Throw <DDBException>();

            act = () => DroneDB.SetTag(ddbPath, string.Empty);

            act.Should().Throw <DDBException>();

            act = () => DroneDB.SetTag(ddbPath, null);

            act.Should().Throw <ArgumentException>();
        }
コード例 #3
0
        public void EndToEnd_Add_Remove()
        {
            const string testFolder = "testAdd";

            if (Directory.Exists(testFolder))
            {
                Directory.Delete(testFolder, true);
            }

            Directory.CreateDirectory(testFolder);
            DroneDB.Init(testFolder);

            File.WriteAllText(Path.Join(testFolder, "file.txt"), "test");
            File.WriteAllText(Path.Join(testFolder, "file2.txt"), "test");
            File.WriteAllText(Path.Join(testFolder, "file3.txt"), "test");

            Assert.Throws <DDBException>(() => DroneDB.Add(testFolder, "invalid"));

            var entry = DroneDB.Add(testFolder, Path.Join(testFolder, "file.txt"))[0];

            entry.Path.Should().Be("file.txt");
            entry.Hash.Should().NotBeNullOrWhiteSpace();

            var entries = DroneDB.Add(testFolder, new[] { Path.Join(testFolder, "file2.txt"), Path.Join(testFolder, "file3.txt") });

            entries.Should().HaveCount(2);

            DroneDB.Remove(testFolder, Path.Combine(testFolder, "file.txt"));

            Assert.Throws <DDBException>(() => DroneDB.Remove(testFolder, "invalid"));
        }
コード例 #4
0
        public void Info_GenericFile_Details()
        {
            const string testFolder = "testInfo";

            if (Directory.Exists(testFolder))
            {
                Directory.Delete(testFolder, true);
            }
            Directory.CreateDirectory(testFolder);

            File.WriteAllText(Path.Join(testFolder, "file.txt"), "test");
            File.WriteAllText(Path.Join(testFolder, "file2.txt"), "test");

            var e = DroneDB.Info(Path.Join(testFolder, "file.txt"), withHash: true)[0];

            Assert.IsNotEmpty(e.Hash);

            // TODO: troubleshoot this and use
            var es = DroneDB.Info(testFolder, true);

            Assert.AreEqual(2, es.Count);
            Assert.AreEqual(EntryType.Generic, es[0].Type);
            Assert.IsTrue(es[0].Size > 0);
            Assert.AreEqual(DateTime.Now.Year, es[0].ModifiedTime.Year);
        }
コード例 #5
0
        public void GenerateMemoryThumbnail_HappyPath_Ok()
        {
            using var tempFile = new TempFile(TestFileUrl, BaseTestFolder);
            var buffer = DroneDB.GenerateThumbnail(tempFile.FilePath, 300);

            buffer.Length.Should().BeGreaterThan(0);
        }
コード例 #6
0
        public void Tag_HappyPath_Ok()
        {
            const string goodTag             = "pippo/pluto";
            const string goodTagWithRegistry = "https://test.com/pippo/pluto";

            using var test = new TestFS(Test3ArchiveUrl, BaseTestFolder);

            var ddbPath = Path.Combine(test.TestFolder, DdbFolder);

            var tag = DroneDB.GetTag(ddbPath);

            tag.Should().BeNull();

            DroneDB.SetTag(ddbPath, goodTag);

            tag = DroneDB.GetTag(ddbPath);

            tag.Should().Be(goodTag);

            DroneDB.SetTag(ddbPath, goodTagWithRegistry);

            tag = DroneDB.GetTag(ddbPath);

            tag.Should().Be(goodTagWithRegistry);
        }
コード例 #7
0
        public void GenerateMemoryTile_HappyPath_Ok()
        {
            using var tempFile = new TempFile(TestGeoTiffUrl, BaseTestFolder);

            var buffer = DroneDB.GenerateMemoryTile(tempFile.FilePath, 18, 64083, 92370, 256, true);

            buffer.Length.Should().BeGreaterThan(0);
        }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
0
        public void Init_NonExistant_Exception()
        {
            Action act = () => DroneDB.Init("nonexistant");

            act.Should().Throw <DDBException>();

            act = () => DroneDB.Init(null);
            act.Should().Throw <DDBException>();
        }
コード例 #11
0
        public void Info_InvalidFile_Exception()
        {
            Action act = () => DroneDB.Info("invalid");

            act.Should().Throw <DDBException>();

            act = () => DroneDB.Info((string)null);
            act.Should().Throw <DDBException>();
        }
コード例 #12
0
        public void Chaddr_NullAttr_Exception()
        {
            using var test = new TestFS(Test3ArchiveUrl, BaseTestFolder);

            var ddbPath = test.TestFolder;

            Action act = () => DroneDB.ChangeAttributes(ddbPath, null);

            act.Should().Throw <ArgumentException>();
        }
コード例 #13
0
        public void Delta_HappyPath_Ok()
        {
            using var source      = new TestFS(TestDelta2ArchiveUrl, BaseTestFolder);
            using var destination = new TestFS(TestDelta1ArchiveUrl, BaseTestFolder);

            var delta = DroneDB.Delta(source.TestFolder, destination.TestFolder);

            delta.Adds.Length.Should().BeGreaterThan(0);
            delta.Removes.Length.Should().BeGreaterThan(0);
        }
コード例 #14
0
        public void Stamp_HappyPath_Ok()
        {
            using var test = new TestFS(Test3ArchiveUrl, BaseTestFolder);

            var ddbPath = Path.Combine(test.TestFolder, DdbFolder);

            var stamp = DroneDB.GetStamp(ddbPath);

            stamp.Checksum.Should().NotBeNull();
            stamp.Entries.Count.Should().BeGreaterThan(0);
        }
コード例 #15
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);
        }
コード例 #16
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));
        }
コード例 #17
0
        public void MoveEntry_SimpleRename_Ok()
        {
            using var test = new TestFS(TestDelta2ArchiveUrl, BaseTestFolder);

            DroneDB.MoveEntry(test.TestFolder, "plutone.txt", "test.txt");

            var res = DroneDB.List(test.TestFolder, test.TestFolder, true);

            res.Should().HaveCount(11);
            res[8].Path.Should().Be("test.txt");
        }
コード例 #18
0
        public void Remove_Nonexistant_Exception()
        {
            Action act = () => DroneDB.Remove("invalid", "");

            act.Should().Throw <DDBException>();

            act = () => DroneDB.Remove("invalid", "wefrfwef");
            act.Should().Throw <DDBException>();

            act = () => DroneDB.Remove(null, "wefrfwef");
            act.Should().Throw <DDBException>();
        }
コード例 #19
0
        public void Remove_NonexistantFile_Exception()
        {
            using var test = new TestFS(Test1ArchiveUrl, BaseTestFolder);

            const string fileName = "elaiuyhrfboeawuyirgfb";

            var ddbPath = Path.Combine(test.TestFolder, "public", "default");

            Action act = () => DroneDB.Remove(ddbPath, Path.Combine(ddbPath, fileName));

            act.Should().Throw <DDBException>();
        }
コード例 #20
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);
        }
コード例 #21
0
        public void Init_EmptyFolder_Ok()
        {
            const string folder = "testInit";

            if (Directory.Exists(folder))
            {
                Directory.Delete(folder, true);
            }
            Directory.CreateDirectory(folder);

            DroneDB.Init(folder).Should().Contain(folder);
            Directory.Exists(Path.Join(folder, ".ddb")).Should().BeTrue();
        }
コード例 #22
0
        public void List_AllFiles_Ok()
        {
            using var test = new TestFS(Test1ArchiveUrl, BaseTestFolder);

            var ddbPath = Path.Combine(test.TestFolder, "public", "default");

            var res = DroneDB.List(ddbPath, Path.Combine(ddbPath, "."), true);

            res.Should().HaveCount(26);

            res = DroneDB.List(ddbPath, ddbPath, true);

            res.Should().HaveCount(26);
        }
コード例 #23
0
        public void Remove_AllFiles_Ok()
        {
            using var test = new TestFS(Test1ArchiveUrl, BaseTestFolder);

            const string fileName = ".";

            var ddbPath = Path.Combine(test.TestFolder, "public", "default");

            DroneDB.Remove(ddbPath, Path.Combine(ddbPath, fileName));

            var res = DroneDB.List(ddbPath, ".", true);

            res.Should().HaveCount(0);
        }
コード例 #24
0
        public void List_Nonexistant_Exception()
        {
            Action act = () => DroneDB.List("invalid", "");

            act.Should().Throw <DDBException>();

            act = () => DroneDB.List("invalid", "wefrfwef");
            act.Should().Throw <DDBException>();

            act = () => DroneDB.List(null, "wefrfwef");
            act.Should().Throw <DDBException>();

            act = () => DroneDB.List("invalid", (string)null);
            act.Should().Throw <DDBException>();
        }
コード例 #25
0
        public void Add_NonExistant_Exception()
        {
            Action act = () => DroneDB.Add("nonexistant", "");

            act.Should().Throw <DDBException>();

            act = () => DroneDB.Add("nonexistant", "test");
            act.Should().Throw <DDBException>();

            act = () => DroneDB.Add(null, "test");
            act.Should().Throw <DDBException>();

            act = () => DroneDB.Add("nonexistant", (string)null);
            act.Should().Throw <DDBException>();
        }
コード例 #26
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);
        }
コード例 #27
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);
        }
コード例 #28
0
        public void List_ExistingFile_Ok()
        {
            using var test = new TestFS(Test1ArchiveUrl, BaseTestFolder);

            var ddbPath = Path.Combine(test.TestFolder, "public", "default");

            var res = DroneDB.List(ddbPath, Path.Combine(ddbPath, "DJI_0027.JPG"));

            res.Should().HaveCount(1);
            var entry = res.First();

            Entry expectedEntry = JsonConvert.DeserializeObject <Entry>(
                "{\"depth\":0,\"hash\":\"3157958dd4f2562c8681867dfd6ee5bf70b6e9595b3e3b4b76bbda28342569ed\",\"properties\":{\"cameraPitch\":-89.9000015258789,\"cameraRoll\":0.0,\"cameraYaw\":-131.3000030517578,\"captureTime\":1466699584000.0,\"focalLength\":3.4222222222222225,\"focalLength35\":20.0,\"height\":2250,\"make\":\"DJI\",\"model\":\"FC300S\",\"orientation\":1,\"sensor\":\"dji fc300s\",\"sensorHeight\":3.4650000000000003,\"sensorWidth\":6.16,\"width\":4000},\"mtime\":1491156087,\"path\":\"DJI_0027.JPG\",\"point_geom\":{\"crs\":{\"properties\":{\"name\":\"EPSG:4326\"},\"type\":\"name\"},\"geometry\":{\"coordinates\":[-91.99408299999999,46.84260499999999,198.5099999999999],\"type\":\"Point\"},\"properties\":{},\"type\":\"Feature\"},\"polygon_geom\":{\"crs\":{\"properties\":{\"name\":\"EPSG:4326\"},\"type\":\"name\"},\"geometry\":{\"coordinates\":[[[-91.99397836402999,46.8422402913,158.5099999999999],[-91.99357489543,46.84247729175999,158.5099999999999],[-91.99418894036,46.84296945989999,158.5099999999999],[-91.99459241001999,46.8427324573,158.5099999999999],[-91.99397836402999,46.8422402913,158.5099999999999]]],\"type\":\"Polygon\"},\"properties\":{},\"type\":\"Feature\"},\"size\":3185449,\"type\":3}");

            entry.Should().BeEquivalentTo(expectedEntry);
        }
コード例 #29
0
        public void Password_HappyPath_Ok()
        {
            using var test = new TestFS(Test1ArchiveUrl, BaseTestFolder);

            var ddbPath = Path.Combine(test.TestFolder, "public", "default");

            DroneDB.VerifyPassword(ddbPath, string.Empty).Should().BeTrue();

            DroneDB.AppendPassword(ddbPath, "testpassword");

            DroneDB.VerifyPassword(ddbPath, "testpassword").Should().BeTrue();
            DroneDB.VerifyPassword(ddbPath, "wrongpassword").Should().BeFalse();

            DroneDB.ClearPasswords(ddbPath);
            DroneDB.VerifyPassword(ddbPath, "testpassword").Should().BeFalse();
        }
コード例 #30
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");
        }