public FixedLengthFileEngineWriteTests()
        {
            A.CallTo(() => _lineBuilder.BuildLine(A <TestRecord> .Ignored))
            .ReturnsLazily((TestRecord r) => r.ToString());

            _lineBuilderFactory = A.Fake <IFixedLengthLineBuilderFactory>();
            A.CallTo(() => _lineBuilderFactory.GetBuilder(A <IFixedLengthLayoutDescriptor> .Ignored))
            .Returns(_lineBuilder);

            _fileEngine = new FixedLengthFileEngine(
                A.Fake <IFixedLengthLayoutDescriptor>(),
                _lineBuilderFactory,
                new FixedLengthLineParserFactory());
        }
        public void ErrorContextShouldProvideAccurateInformation()
        {
            var engine = new FixedLengthFileEngine(
                layout,
                A.Fake <IFixedLengthLineBuilderFactory>(),
                lineParserFactory,
                HandleError);

            using (var reader = new StringReader(TestData))
                engine.Read <Record>(reader).ToList();

            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));
        }