public void Write(DbaseRecord record) { if (record == null) { throw new ArgumentNullException(nameof(record)); } record.Write(Writer); }
public void Write(DbaseRecord record) { if (record == null) { throw new ArgumentNullException(nameof(record)); } if (_disposed) { throw new ObjectDisposedException(nameof(DbaseBinaryWriter)); } record.Write(Writer); }
public AnonymousDbaseRecordEnumeratorOverStreamWithExpectedBytesTests() { var fixture = new Fixture(); fixture.CustomizeWordLength(); fixture.CustomizeDbaseFieldName(); fixture.CustomizeDbaseFieldLength(); fixture.CustomizeDbaseDecimalCount(); fixture.CustomizeDbaseField(); fixture.CustomizeDbaseCodePage(); fixture.CustomizeDbaseRecordCount(); fixture.CustomizeDbaseSchema(); _record1 = new FakeDbaseRecord { Id = { Value = fixture.Create <int>() } }; _record2 = new FakeDbaseRecord { Id = { Value = fixture.Create <int>() } }; var header = new DbaseFileHeader( fixture.Create <DateTime>(), DbaseCodePage.Western_European_ANSI, new DbaseRecordCount(2), new FakeDbaseSchema()); var stream = new MemoryStream(); long position; using (var writer = new BinaryWriter(stream, Encoding.UTF8, true)) { header.Write(writer); writer.Flush(); position = stream.Position; _record1.Write(writer); _record2.Write(writer); writer.Write(DbaseRecord.EndOfFile); writer.Flush(); } stream.Position = position; _reader = new DisposableBinaryReader(stream, Encoding.UTF8, false); _sut = header.CreateAnonymousDbaseRecordEnumerator(_reader); }
public DbaseRecordEnumeratorWithLongerStreamTests() { var fixture = new Fixture(); fixture.CustomizeWordLength(); fixture.CustomizeDbaseFieldName(); fixture.CustomizeDbaseFieldLength(); fixture.CustomizeDbaseDecimalCount(); fixture.CustomizeDbaseField(); fixture.CustomizeDbaseCodePage(); fixture.CustomizeDbaseRecordCount(); fixture.CustomizeDbaseSchema(); _record = new FakeDbaseRecord { Id = { Value = fixture.Create <int>() } }; var header = new DbaseFileHeader( fixture.Create <DateTime>(), DbaseCodePage.Western_European_ANSI, new DbaseRecordCount(1), new FakeDbaseSchema()); var stream = new MemoryStream(); long position; using (var writer = new BinaryWriter(stream, Encoding.UTF8, true)) { header.Write(writer); writer.Flush(); position = stream.Position; _record.Write(writer); writer.Write(DbaseRecord.EndOfFile); writer.Write(fixture.CreateMany <byte>(10).ToArray()); writer.Flush(); } stream.Position = position; _reader = new DisposableBinaryReader(stream, Encoding.UTF8, false); _sut = header.CreateDbaseRecordEnumerator <FakeDbaseRecord>(_reader); }