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(); }
private IEnumerable <string> BuildOccurrenceRows(RowBuilder rowBuilder) { var occurrences = fixture.GetOccurrencesAsync().Result; foreach (var occurrence in occurrences) { yield return(rowBuilder.AddField(occurrence.OccurrenceID) .AddField(occurrence.BasisOfRecord) .AddField(occurrence.ScientificName) .AddField(occurrence.EventDate.ToString("yyyy-MM-dd")) .AddField(occurrence.DecimalLatitude) .AddField(occurrence.DecimalLongitude) .AddField(occurrence.GeodeticDatum) .Build()); } }