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")); }
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>(); }
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); }
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"); }
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(); }
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); }