public void CanReadWriteNull() { var sut = _fixture.Create <DbaseDateTime>(); 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 DbaseDateTime(sut.Field); result.Read(reader); Assert.Equal(sut.Field, result.Field); Assert.Equal(sut.Value, result.Value); } } }
public void CanReadWriteNull() { _fixture.CustomizeDbaseDateTimeWithoutValue(); var sut = _fixture.Create <DbaseDateTime>(); 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 DbaseDateTime(sut.Field); result.Read(reader); Assert.Equal(sut.Field, result.Field); Assert.Throws <FormatException>(() => sut.Value); } } }
public void DateTimeMillisecondsAreRemovedUponConstruction() { var field = new DbaseField( _fixture.Create <DbaseFieldName>(), DbaseFieldType.DateTime, _fixture.Create <ByteOffset>(), new DbaseFieldLength(15), new DbaseDecimalCount(0)); var sut = new DbaseDateTime(field, new DateTime(1, 1, 1, 1, 1, 1, 1)); Assert.Equal(new DateTime(1, 1, 1, 1, 1, 1, 0), sut.Value); }
public void CanNotReadPastEndOfStream() { var sut = _fixture.Create <DbaseDateTime>(); 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 DbaseDateTime(sut.Field); Assert.Throws <EndOfStreamException>(() => result.Read(reader)); } } }
public void Visit(DbaseDateTime value) { value.Value = _fixture.Create <DateTime>(); }
public void Inspect(DbaseDateTime value) { value.Value = _fixture.Create <DateTime?>(); }
public void Inspect(DbaseDateTime value) { HashCode = value.Value.HasValue ? value.Value.Value.GetHashCode() : 0; }
public void Inspect(DbaseDateTime value) { Value = value.Value; }
public void Inspect(DbaseDateTime value) { Comparer = new DelegatingDbaseFieldValueEqualityComparer <DbaseDateTime>( new DbaseDateTimeEqualityComparer()); }
public void Visit(DbaseDateTime value) { HashCode = value.Value.GetHashCode(); }