Exemplo n.º 1
0
        public void ReadingCharacterWithDateTimeValueHasExpectedResult()
        {
            var value  = _fixture.Create <DateTime>();
            var fields = new[]
            {
                new DbaseField(
                    _fixture.Create <DbaseFieldName>(),
                    DbaseFieldType.DateTime,
                    ByteOffset.Initial,
                    new DbaseFieldLength(15),
                    new DbaseDecimalCount(0)
                    )
            };
            var values = new DbaseFieldValue[]
            {
                new DbaseDateTime(
                    fields[0],
                    value
                    )
            };

            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream, Encoding.ASCII, true))
                {
                    new AnonymousDbaseRecord(values).Write(writer);
                    writer.Flush();
                }

                stream.Position = 0;

                using (var reader = new BinaryReader(stream, Encoding.ASCII, true))
                {
                    fields[0] = new DbaseField(
                        fields[0].Name,
                        DbaseFieldType.Character,
                        ByteOffset.Initial,
                        new DbaseFieldLength(15),
                        new DbaseDecimalCount(0)
                        );

                    var sut = new AnonymousDbaseRecord(fields);

                    //Act
                    sut.Read(reader);

                    Assert.False(sut.IsDeleted);
                    Assert.Equal(new DbaseFieldValue[]
                    {
                        new DbaseDateTime(
                            fields[0],
                            value
                            )
                    }, sut.Values, new DbaseFieldValueEqualityComparer());
                }
            }
        }
Exemplo n.º 2
0
            public FakeDbaseRecord()
            {
                Id = new DbaseNumber(Schema.Id);

                Values = new DbaseFieldValue[] { Id };
            }