public void ToBytesHasExpectedResult() { var sut = new PointShapeContent(_fixture.Create <PointM>()); var result = sut.ToBytes(); using (var stream = new MemoryStream()) using (var writer = new BinaryWriter(stream)) { sut.Write(writer); writer.Flush(); Assert.Equal(stream.ToArray(), result); } }
public void AnonymousHasExpectedResult() { var sut = new PointShapeContent(_fixture.Create <PointM>()); var result = sut.Anonymous(); using (var stream = new MemoryStream()) using (var writer = new BinaryWriter(stream)) { sut.Write(writer); writer.Flush(); Assert.Equal(sut.ShapeType, result.ShapeType); Assert.Equal(sut.ContentLength, result.ContentLength); Assert.Equal( stream.ToArray(), Assert.IsType <AnonymousShapeContent>(result).Content); } }
public void ReadPointCanReadWrittenPointShape() { var sut = new PointShapeContent(_fixture.Create <Point>()); 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 = (PointShapeContent)PointShapeContent.ReadPoint(reader); Assert.Equal(sut.Shape, result.Shape); Assert.Equal(sut.ShapeType, result.ShapeType); Assert.Equal(sut.ContentLength, result.ContentLength); } } }