Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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)
                        );
                }
            }
        }
Exemplo n.º 4
0
 public void ReadPolygonReaderCanNotBeNull()
 {
     new GuardClauseAssertion(_fixture)
     .Verify(Methods.Select(() => PolygonShapeContent.ReadPolygon(null)));
 }