Exemplo n.º 1
0
        public void EndToEnd_Add_Remove()
        {
            const string testFolder = "testAdd";

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

            Directory.CreateDirectory(testFolder);
            DDBWrapper.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>(() => DDBWrapper.Add(testFolder, "invalid"));

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

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

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

            entries.Should().HaveCount(2);

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

            Assert.Throws <DDBException>(() => DDBWrapper.Remove(testFolder, "invalid"));
        }
Exemplo n.º 2
0
        public void Add_NonExistant_Exception()
        {
            Action act = () => DDBWrapper.Add("nonexistant", "");

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

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

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

            act = () => DDBWrapper.Add("nonexistant", (string)null);
            act.Should().Throw <DDBException>();
        }
Exemplo n.º 3
0
        public void MetaUnset_Ok()
        {
            using var area = new TestArea("metaUnsetOkTest");
            DDBWrapper.Init(area.TestFolder);

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

            File.WriteAllText(f, null);

            DDBWrapper.Add(area.TestFolder, f);

            DDBWrapper.MetaSet(area.TestFolder, "abc", "[1,2,3]");
            DDBWrapper.MetaUnset(area.TestFolder, "abc", f).Should().Be(0);
            DDBWrapper.MetaUnset(area.TestFolder, "abc").Should().Be(1);
            DDBWrapper.MetaUnset(area.TestFolder, "abc").Should().Be(0);
        }
Exemplo n.º 4
0
        public void MetaSet_Ok()
        {
            using var area = new TestArea("metaSetOkTest");
            DDBWrapper.Init(area.TestFolder);

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

            File.WriteAllText(f, null);

            DDBWrapper.Add(area.TestFolder, f);

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

            DDBWrapper.MetaSet(area.TestFolder, "test", "abc", f).Data.ToObject <string>().Should().Be("abc");
            DDBWrapper.MetaSet(area.TestFolder, "test", "efg", f).Data.ToObject <string>().Should().Be("efg");
        }
Exemplo n.º 5
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 = DDBWrapper.Add(ddbPath, destPath);

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

            DDBWrapper.IsBuildable(ddbPath, Path.GetFileName(destPath)).Should().BeTrue();
        }
Exemplo n.º 6
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);

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

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

            File.Move(tempFile.FilePath, destPath);

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

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