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 ShouldBuildFieldMetaDataArray() { var fieldsMetaData = FieldsMetaDataBuilder.Fields() .AddField(_ => _.Index(0).Term(Terms.identificationID)) .AddField(_ => _.Index(1).Term(Terms.scientificName)) .Build(); Assert.NotEmpty(fieldsMetaData); }
public void ShouldBuildFieldMetaDataArrayWithIndexAndDefault() { var fieldsMetaData = FieldsMetaDataBuilder.Fields() .AddField(_ => _.Term(Terms.geodeticDatum).Default("WGS84")) .AutomaticallyIndex() .AddField(_ => _.Term(Terms.identificationID)) .AddField(_ => _.Term(Terms.scientificName)) .Build(); Assert.Equal(3, fieldsMetaData.Length); var fieldsMetaData1 = new FieldMetaData(null, fieldsMetaData); Assert.Equal(3, fieldsMetaData1.Length); }
public void Setup() { Random rand = new Random(); sequence = Enumerable.Range(0, fields.Length - 1) .OrderBy(n => rand.Next()) .ToArray(); var metaData = FieldsMetaDataBuilder.Fields() .AutomaticallyIndex() .AddField(_ => _.Term("id")) .AddField(_ => _.Term(Terms.taxonID)) .AddField(_ => _.Term(Terms.acceptedNameUsageID)) .AddField(_ => _.Term(Terms.parentNameUsageID)) .AddField(_ => _.Term(Terms.nameAccordingToID)) .AddField(_ => _.Term(Terms.scientificName)) .AddField(_ => _.Term(Terms.acceptedNameUsage)) .AddField(_ => _.Term(Terms.parentNameUsage)) .AddField(_ => _.Term(Terms.nameAccordingTo)) .AddField(_ => _.Term(Terms.higherClassification)) .AddField(_ => _.Term(Terms.@class)) .AddField(_ => _.Term(Terms.order)) .AddField(_ => _.Term(Terms.family)) .AddField(_ => _.Term(Terms.genus)) .AddField(_ => _.Term(Terms.subgenus)) .AddField(_ => _.Term(Terms.specificEpithet)) .AddField(_ => _.Term(Terms.infraspecificEpithet)) .AddField(_ => _.Term(Terms.taxonRank)) .AddField(_ => _.Term(Terms.scientificNameAuthorship)) .AddField(_ => _.Term(Terms.taxonomicStatus)) .AddField(_ => _.Term(Terms.modified)) .AddField(_ => _.Term(Terms.license)) .AddField(_ => _.Term(Terms.bibliographicCitation)) .AddField(_ => _.Term(Terms.references)) .Build(); var coreFileType = new CoreFileType(); foreach (var m in metaData) { coreFileType.Field.Add(m); } var defaultFactory = new DefaultFactory(); fileMetaData = defaultFactory.CreateCoreMetaData(coreFileType); rowFactory = defaultFactory.CreateRowFactory(); }
public void Setup() { metaData = FieldsMetaDataBuilder.Fields() .AutomaticallyIndex() .AddField(_ => _.Term("id")) .AddField(_ => _.Term(Terms.taxonID)) .AddField(_ => _.Term(Terms.acceptedNameUsageID)) .AddField(_ => _.Term(Terms.parentNameUsageID)) .AddField(_ => _.Term(Terms.nameAccordingToID)) .AddField(_ => _.Term(Terms.scientificName)) .AddField(_ => _.Term(Terms.acceptedNameUsage)) .AddField(_ => _.Term(Terms.parentNameUsage)) .AddField(_ => _.Term(Terms.nameAccordingTo)) .AddField(_ => _.Term(Terms.higherClassification)) .AddField(_ => _.Term(Terms.@class)) .AddField(_ => _.Term(Terms.order)) .AddField(_ => _.Term(Terms.family)) .AddField(_ => _.Term(Terms.genus)) .AddField(_ => _.Term(Terms.subgenus)) .AddField(_ => _.Term(Terms.specificEpithet)) .AddField(_ => _.Term(Terms.infraspecificEpithet)) .AddField(_ => _.Term(Terms.taxonRank)) .AddField(_ => _.Term(Terms.scientificNameAuthorship)) .AddField(_ => _.Term(Terms.taxonomicStatus)) .AddField(_ => _.Term(Terms.modified)) .AddField(_ => _.Term(Terms.license)) .AddField(_ => _.Term(Terms.bibliographicCitation)) .AddField(_ => _.Term(Terms.references)) .Build(); coreFileType = new CoreFileType(); foreach (var m in metaData) { coreFileType.Field.Add(m); } defaultFactory = new DefaultFactory(); }