コード例 #1
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);
        }
コード例 #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 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);
        }
コード例 #4
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>();
        }
コード例 #5
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);
        }
コード例 #6
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");
        }
コード例 #7
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>();
        }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
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();
        }
コード例 #11
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);
        }
コード例 #12
0
        public void Chaddr_HappyPath_Ok()
        {
            using var test = new TestFS(Test3ArchiveUrl, BaseTestFolder);

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

            var res = DroneDB.ChangeAttributes(ddbPath, new Dictionary <string, object> {
                { "public", true }
            });

            res["public"].Should().Be(true);

            res = DroneDB.ChangeAttributes(ddbPath, new Dictionary <string, object> {
                { "public", false }
            });

            res["public"].Should().Be(false);
        }
コード例 #13
0
        public void Add_ImageFile_Ok()
        {
            using var test = new TestFS(Test1ArchiveUrl, BaseTestFolder);

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

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

            DroneDB.Remove(ddbPath, Path.Combine(ddbPath, "DJI_0023.JPG"));

            var destPath = Path.Combine(ddbPath, Path.GetFileName(tempFile.FilePath));

            File.Move(tempFile.FilePath, destPath);

            var res = DroneDB.Add(ddbPath, destPath);

            res.Count.Should().Be(1);
        }
コード例 #14
0
        public void IsBuildable_PointCloud_True()
        {
            using var test = new TestFS(Test1ArchiveUrl, BaseTestFolder);

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

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

            var destPath = Path.Combine(ddbPath, Path.GetFileName(tempFile.FilePath));

            File.Move(tempFile.FilePath, destPath);

            var res = DroneDB.Add(ddbPath, destPath);

            res.Count.Should().Be(1);

            DroneDB.IsBuildable(ddbPath, Path.GetFileName(destPath)).Should().BeTrue();
        }
コード例 #15
0
        public void List_ExistingFileSubFolder_Ok()
        {
            using var fs = new TestFS(Test1ArchiveUrl, nameof(DroneDBTests));

            const string fileName             = "Sub/20200610_144436.jpg";
            const int    expectedDepth        = 1;
            const int    expectedSize         = 8248241;
            var          expectedType         = EntryType.GeoImage;
            const string expectedHash         = "f27ddc96daf9aeff3c026de8292681296c3e9d952b647235878c50f2b7b39e94";
            var          expectedModifiedTime = new DateTime(2020, 06, 10, 14, 44, 36);
            var          expectedMeta         = JsonConvert.DeserializeObject <Dictionary <string, object> >(
                "{\"captureTime\":1591800276004.8,\"focalLength\":4.16,\"focalLength35\":26.0,\"height\":3024,\"make\":\"samsung\",\"model\":\"SM-G950F\",\"orientation\":1,\"sensor\":\"samsung sm-g950f\",\"sensorHeight\":4.32,\"sensorWidth\":5.76,\"width\":4032}");
            //const double expectedLatitude = 45.50027;
            //const double expectedLongitude = 10.60667;
            //const double expectedAltitude = 141;


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

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

            res.Should().HaveCount(1);

            var file = res.First();

            file.Path.Should().Be(fileName);
            // TODO: Handle different timezones
            file.ModifiedTime.Should().BeCloseTo(expectedModifiedTime, new TimeSpan(6, 0, 0));
            file.Hash.Should().Be(expectedHash);
            file.Depth.Should().Be(expectedDepth);
            file.Size.Should().Be(expectedSize);
            file.Type.Should().Be(expectedType);
            file.Properties.Should().BeEquivalentTo(expectedMeta);
            file.PointGeometry.Should().NotBeNull();
            //file.PointGeometry.Coordinates.Latitude.Should().BeApproximately(expectedLatitude, 0.00001);
            //file.PointGeometry.Coordinates.Longitude.Should().BeApproximately(expectedLongitude, 0.00001);
            //file.PointGeometry.Coordinates.Altitude.Should().Be(expectedAltitude);
        }
コード例 #16
0
 public void Clean_Domain()
 {
     TempFile.CleanDomain(BaseTestFolder);
     TestFS.ClearCache(BaseTestFolder);
 }
コード例 #17
0
        public void IsBuildable_TextFile_False()
        {
            using var test = new TestFS(TestDelta2ArchiveUrl, BaseTestFolder);

            DroneDB.IsBuildable(test.TestFolder, "lol.txt").Should().BeFalse();
        }