public void ShouldBuildMetaFile() { var context = new BuilderContext("."); var fieldsMetaDataBuilder = FieldsMetaDataBuilder.Fields() .AutomaticallyIndex() .AddField(_ => _.Term(Terms.identificationID)) .AddField(_ => _.Term(Terms.scientificName)); var coreFile = CoreFileMetaDataBuilder.File("taxon.txt") .Encoding(Encoding.UTF8) .Index(0) .RowType(RowTypes.Taxon) .AddFields(fieldsMetaDataBuilder); var extensionFieldsBuilder = FieldsMetaDataBuilder.Fields() .AutomaticallyIndex() .AddField(_ => _.Term(Terms.identificationID)) .AddField(_ => _.Term(Terms.sampleSizeValue)); var extensionFile = ExtensionFileMetaDataBuilder.File("occurrent.txt") .CoreIndex(0) .RowType(RowTypes.Occurrence) .AddFields(extensionFieldsBuilder); ArchiveMetaDataBuilder.CoreFile(coreFile) .Context(context) .AddExtension(extensionFile) .Serialize(); }
public void ShouldBuildArchiveFromExistingFile() { var fieldMetaDataBuilder = FieldsMetaDataBuilder.Fields() .AutomaticallyIndex() .AddField(_ => _.Term(Terms.taxonID)) .AddField(_ => _.Term(Terms.vernacularName)) .AddField(_ => _.Term(Terms.language)); var fileMetaData = CoreFileMetaDataBuilder.File("taxon.txt") .FieldsEnclosedBy("\"") .FieldsTerminatedBy(",") .LinesTerminatedBy("\\n") .IgnoreHeaderLines(1) .Encoding(Encoding.UTF8) .Index(0) .RowType(RowTypes.Taxon) .AddFields(fieldMetaDataBuilder); var fileBuider = FileBuilder.MetaData(fileMetaData) .UseExistingFile("./resources/whales/whales.txt"); ArchiveWriter.CoreFile(fileBuider, fileMetaData) .Build("whales.zip"); Assert.True(File.Exists("whales.zip")); using (var archive = new ArchiveReader("whales.zip")) { var whales = archive.CoreFile .DataRows .Select(n => n[Terms.vernacularName]); Assert.Equal(new[] { "sperm whale", "cachalot", "gray whale" }, whales); } }
public void ShoudBuildFileMetaData() { var fieldsMetaDataBuilder = fixture.OccurrenceFieldsMetaDataBuilder; var fileMetaData = CoreFileMetaDataBuilder.File("taxon.txt") .Encoding(Encoding.UTF8) .Index(0) .RowType(RowTypes.Taxon) .AddFields(fieldsMetaDataBuilder) .Build(); Assert.Equal("UTF-8", fileMetaData.Encoding); }
public async Task ShouldBuildArchive() { var context = BuilderContext.Default; var occurrences = await fixture.GetOccurrencesAsync(); var occurrenceMetaDataBuilder = fixture.OccurrenceFieldsMetaDataBuilder; var coreFileMetaDataBuilder = CoreFileMetaDataBuilder.File("occurrence.txt") .IgnoreHeaderLines(1) .Encoding(Encoding.UTF8) .Index(0) .RowType(RowTypes.Occurrence) .AddFields(occurrenceMetaDataBuilder); var coreFileBuilder = FileBuilder.MetaData(coreFileMetaDataBuilder) .Context(context) .BuildRows(rowBuilder => BuildCoreRows(rowBuilder)); var multimedia = await fixture.GetMultimediaAsync(); var multimediaMetaDataBuilder = fixture.MultimediaMetaDataBuilder; var extensionFileMetaDataBuilder = ExtensionFileMetaDataBuilder.File("multimedia.txt") .IgnoreHeaderLines(1) .Encoding(Encoding.UTF8) .CoreIndex(0) .RowType(RowTypes.Occurrence) .AddFields(multimediaMetaDataBuilder); var extensionFileBuilder = FileBuilder.MetaData(extensionFileMetaDataBuilder) .Context(context) .BuildRows(rowBuilder => BuildExtensionRows(rowBuilder)); var archiveName = "archivexxx.zip"; ArchiveWriter.CoreFile(coreFileBuilder, coreFileMetaDataBuilder) .Context(context) .AddExtensionFile(extensionFileBuilder, extensionFileMetaDataBuilder) .AddExtraFile("resources/ExtraData.txt") .Build(archiveName); Assert.True(File.Exists(archiveName)); context.Cleanup(); }
public void ShouldBuildOccurrenceFile() { var fieldsMetaDataBuilder = fixture.OccurrenceFieldsMetaDataBuilder; var context = new BuilderContext("."); var occurrenceMetaDataBuilder = CoreFileMetaDataBuilder.File("occurrence.txt") .IgnoreHeaderLines(1) .Encoding(Encoding.UTF8) .Index(0) .RowType(RowTypes.Occurrence) .AddFields(fieldsMetaDataBuilder) .Build(); var coreFileMetaData = new CoreFileMetaData(occurrenceMetaDataBuilder); var fileBuilder = FileBuilder.MetaData(coreFileMetaData) .Context(context) .BuildRows(rowBuilder => BuildOccurrenceRows(rowBuilder)); var fileName = fileBuilder.Build(); Assert.True(File.Exists(fileName)); }