Esempio n. 1
0
        public ShapeRecordEnumeratorOverStreamWithExpectedBytesTests()
        {
            var fixture = new Fixture();

            fixture.CustomizeShapeRecordCount();
            fixture.CustomizeWordLength();

            var content = new PointShapeContent(new Point(1.0, 1.0));
            var number  = RecordNumber.Initial;

            _record1 = content.RecordAs(number);
            _record2 = content.RecordAs(number.Next());
            var header = new ShapeFileHeader(
                ShapeFileHeader.Length.Plus(_record1.Length).Plus(_record2.Length),
                ShapeType.Point,
                fixture.Create <BoundingBox3D>());
            var stream = new MemoryStream();

            using (var writer = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                header.Write(writer);
                _record1.Write(writer);
                _record2.Write(writer);
                writer.Flush();
            }

            stream.Position = 100;

            _reader = new DisposableBinaryReader(stream, Encoding.UTF8, false);
            _sut    = header.CreateShapeRecordEnumerator(_reader);
        }
        public AnonymousDbaseRecordEnumeratorOverStreamWithEndOfFileTests()
        {
            var fixture = new Fixture();

            fixture.CustomizeWordLength();
            fixture.CustomizeDbaseFieldName();
            fixture.CustomizeDbaseFieldLength();
            fixture.CustomizeDbaseDecimalCount();
            fixture.CustomizeDbaseField();
            fixture.CustomizeDbaseCodePage();
            fixture.CustomizeDbaseRecordCount();
            fixture.CustomizeDbaseSchema();

            var  header = fixture.Create <DbaseFileHeader>();
            var  stream = new MemoryStream();
            long position;

            using (var writer = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                header.Write(writer);
                writer.Flush();
                position = stream.Position;
                writer.Write(DbaseRecord.EndOfFile);
                writer.Flush();
            }

            stream.Position = position;
            _reader         = new DisposableBinaryReader(stream, Encoding.UTF8, false);
            _sut            = header.CreateAnonymousDbaseRecordEnumerator(_reader);
        }
Esempio n. 3
0
        public ShapeRecordEnumeratorWithShorterStreamTests()
        {
            var fixture = new Fixture();

            fixture.CustomizeShapeRecordCount();
            fixture.CustomizeWordLength();

            var content = new PointShapeContent(new PointM(1.0, 1.0));
            var number  = RecordNumber.Initial;

            _record = content.RecordAs(number);
            var header = new ShapeFileHeader(
                ShapeFileHeader.Length.Plus(_record.Length.Times(2)),
                ShapeType.Point,
                fixture.Create <BoundingBox3D>());
            var stream = new MemoryStream();

            using (var writer = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                header.Write(writer);
                _record.Write(writer);
                writer.Write(fixture.CreateMany <byte>(_record.Length.ToByteLength().ToInt32() / 2).ToArray());
                writer.Flush();
            }

            stream.Position = 100;

            _reader = new DisposableBinaryReader(stream, Encoding.UTF8, false);
            _sut    = header.CreateShapeRecordEnumerator(_reader);
        }
Esempio n. 4
0
        public ShapeRecordEnumeratorOverStreamWithoutBytesTests()
        {
            var fixture = new Fixture();

            fixture.CustomizeShapeRecordCount();
            fixture.CustomizeWordLength();

            var header = new ShapeFileHeader(
                fixture.Create <WordLength>(),
                fixture.Create <ShapeType>(),
                fixture.Create <BoundingBox3D>());

            _reader = new DisposableBinaryReader(new MemoryStream(), Encoding.UTF8, false);
            _sut    = header.CreateShapeRecordEnumerator(_reader);
        }
Esempio n. 5
0
        public AnonymousDbaseRecordEnumeratorWithEmptyStreamTests()
        {
            var fixture = new Fixture();

            fixture.CustomizeWordLength();
            fixture.CustomizeDbaseFieldName();
            fixture.CustomizeDbaseFieldLength();
            fixture.CustomizeDbaseDecimalCount();
            fixture.CustomizeDbaseField();
            fixture.CustomizeDbaseCodePage();
            fixture.CustomizeDbaseRecordCount();
            fixture.CustomizeDbaseSchema();

            var header = fixture.Create <DbaseFileHeader>();

            _reader = new DisposableBinaryReader(new MemoryStream(), Encoding.UTF8, false);
            _sut    = header.CreateAnonymousDbaseRecordEnumerator(_reader);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }