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