Exemple #1
0
        public void ReadPolygonCanReadWrittenPolygonShape()
        {
            var shape = _fixture.Create <Polygon>();
            var sut   = new PolygonShapeContent(shape);

            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 = (PolygonShapeContent)PolygonShapeContent.ReadPolygon(reader);

                    Assert.Equal(sut.Shape, result.Shape);
                    Assert.Equal(sut.ShapeType, result.ShapeType);
                    Assert.Equal(sut.ContentLength, result.ContentLength);
                }
            }
        }
Exemple #2
0
        public void ReadPolygonCanReadWrittenNullShape()
        {
            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream, Encoding.ASCII, true))
                {
                    NullShapeContent.Instance.Write(writer);
                    writer.Flush();
                }

                stream.Position = 0;

                using (var reader = new BinaryReader(stream, Encoding.ASCII, true))
                {
                    var result = PolygonShapeContent.ReadPolygon(reader);

                    Assert.Equal(NullShapeContent.Instance, result);
                }
            }
        }
Exemple #3
0
        public void ReadPolygonCanNotReadOtherShapeType(ShapeType other)
        {
            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream, Encoding.ASCII, true))
                {
                    writer.WriteInt32LittleEndian((int)other);

                    writer.Flush();
                }

                stream.Position = 0;

                using (var reader = new BinaryReader(stream, Encoding.ASCII, true))
                {
                    Assert.Throws <ShapeRecordContentException>(
                        () => PolygonShapeContent.ReadPolygon(reader)
                        );
                }
            }
        }
Exemple #4
0
 public void ReadPolygonReaderCanNotBeNull()
 {
     new GuardClauseAssertion(_fixture)
     .Verify(Methods.Select(() => PolygonShapeContent.ReadPolygon(null)));
 }