Example #1
0
        public void CanReadWriteNull()
        {
            var sut = _fixture.Create <DbaseDate>();

            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 DbaseDate(sut.Field);
                    result.Read(reader);

                    Assert.Equal(sut.Field, result.Field);
                    Assert.Equal(sut.Value, result.Value);
                }
            }
        }
Example #2
0
        public void DateTimeHoursMinutesSecondsAndMillisecondsAreRemovedUponConstruction()
        {
            var field = new DbaseField(
                _fixture.Create <DbaseFieldName>(),
                DbaseFieldType.Date,
                _fixture.Create <ByteOffset>(),
                new DbaseFieldLength(8),
                new DbaseDecimalCount(0));
            var sut = new DbaseDate(field, new DateTime(1, 1, 1, 1, 1, 1, 1));

            Assert.Equal(new DateTime(1, 1, 1, 0, 0, 0, 0), sut.Value);
        }
Example #3
0
        public void CanNotReadPastEndOfStream()
        {
            var sut = _fixture.Create <DbaseDate>();

            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream, Encoding.ASCII, true))
                {
                    writer.Write(_fixture.CreateMany <byte>(new Random().Next(0, 7)).ToArray());
                    writer.Flush();
                }

                stream.Position = 0;

                using (var reader = new BinaryReader(stream, Encoding.ASCII, true))
                {
                    var result = new DbaseDate(sut.Field);
                    Assert.Throws <EndOfStreamException>(() => result.Read(reader));
                }
            }
        }
 public void Visit(DbaseDate value)
 {
     value.Value = _fixture.Create <DateTime?>();
 }
Example #5
0
 public void Visit(DbaseDate value)
 {
     HashCode = value.Value?.GetHashCode() ?? 0;
 }
Example #6
0
 public void Visit(DbaseDate value)
 {
     Comparer = new DelegatingDbaseFieldValueEqualityComparer <DbaseDate>(
         new DbaseDateEqualityComparer());
 }