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 ShouldBuildExtensionFile() { var multimediaMetaDataBuilder = fixture.MultimediaMetaDataBuilder; var fileMetaData = ExtensionFileMetaDataBuilder.File("multimedia.txt") .Encoding(Encoding.UTF8) .CoreIndex(0) .RowType(RowTypes.Occurrence) .AddFields(multimediaMetaDataBuilder) .Build(); Assert.Equal("UTF-8", fileMetaData.Encoding); Assert.Equal(0, fileMetaData.Coreid.Index); }
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(); }