Exemple #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);
        }
Exemple #2
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);
        }
Exemple #3
0
        public void CreateShapeRecordEnumeratorReturnsExpectedResult()
        {
            var sut = new ShapeFileHeader(
                _fixture.Create <WordLength>(),
                _fixture.Create <ShapeType>(),
                _fixture.Create <BoundingBox3D>());

            Assert.IsAssignableFrom <IEnumerator <ShapeRecord> >(sut.CreateShapeRecordEnumerator(_fixture.Create <BinaryReader>()));
        }
Exemple #4
0
        public void CreateShapeRecordEnumeratorThrowsWhenReaderIsNull()
        {
            var sut = new ShapeFileHeader(
                _fixture.Create <WordLength>(),
                _fixture.Create <ShapeType>(),
                _fixture.Create <BoundingBox3D>());

            Assert.Throws <ArgumentNullException>(() => sut.CreateShapeRecordEnumerator(null));
        }
Exemple #5
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);
        }