コード例 #1
0
        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);
                }
        }
コード例 #2
0
        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);
                }
        }
コード例 #3
0
        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);
                }
            }
        }