public LayoutParser() { this.Encoding = Encoding.Default; var factory = new FixedLengthFileEngineFactory(); var layouts = new ILayoutDescriptor <IFixedFieldSettingsContainer>[] { new T0HeaderLayout(), new T1ResumoLayout(), new T2EnderecoLayout(), new T3BilheteLayout(), new T4ServicoLayout(), new T5DescontoLayout(), new T9TrailerLayout(), }; this.reader = (FixedLengthFileMultiEngine)factory.GetEngine(layouts, ChooseLayout); // while Read(StreamWriter) is not exposed in the interface }
public async Task MultiEngineErrorContextShouldProvideAccurateInformation() { var engine = new FixedLengthFileMultiEngine( new[] { layout }, (l, i) => typeof(Record), A.Fake <IFixedLengthLineBuilderFactory>(), lineParserFactory, new DefaultFixedLengthMasterDetailStrategy(), HandleError); using (var reader = new StringReader(TestData)) await engine.ReadAsync(reader); Assert.Equal(3, errorContexts.Count); Assert.Equal(new[] { 1, 2, 3 }, errorContexts.Select(ctx => ctx.LineNumber)); Assert.Equal(TestData.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries), errorContexts.Select(ctx => ctx.Line)); Assert.All(errorContexts, ctx => Assert.Equal("Parsing failed!", ctx.Exception.Message)); }