public void CanReadWriteNull() { var sut = _fixture.Create <DbaseNullableDateTimeOffset>(); sut.Value = null; using (var stream = new MemoryStream()) { using (var writer = new BinaryWriter(stream, Encoding.ASCII, true)) { sut.Write(writer); writer.Flush(); } stream.Position = 0; using (var reader = new BinaryReader(stream, Encoding.ASCII, true)) { var result = new DbaseNullableDateTimeOffset(sut.Field); result.Read(reader); Assert.Equal(sut.Field, result.Field); Assert.Equal(sut.Value, result.Value); } } }
public void CanNotReadPastEndOfStream() { var sut = _fixture.Create <DbaseNullableDateTimeOffset>(); using (var stream = new MemoryStream()) { using (var writer = new BinaryWriter(stream, Encoding.ASCII, true)) { writer.Write(_fixture.CreateMany <byte>(new Random().Next(0, 14)).ToArray()); writer.Flush(); } stream.Position = 0; using (var reader = new BinaryReader(stream, Encoding.ASCII, true)) { var result = new DbaseNullableDateTimeOffset(sut.Field); Assert.Throws <EndOfStreamException>(() => result.Read(reader)); } } }