public void WriteManyOnDisposedInstanceHasExpectedResult()
        {
            var shapeType       = _fixture.Create <ShapeType>();
            var recordCount     = _fixture.Create <ShapeRecordCount>();
            var expectedRecords = GenerateManyRecords(shapeType, recordCount);
            var length          = expectedRecords.Aggregate(ShapeFileHeader.Length,
                                                            (result, current) => result.Plus(current.Length));
            var boundingBox = expectedRecords.Aggregate(BoundingBox3D.Empty,
                                                        (result, current) =>
            {
                if (current.Content is PointShapeContent pointContent)
                {
                    return(result.ExpandWith(BoundingBox3D.FromGeometry(pointContent.Shape)));
                }
                if (current.Content is PolyLineMShapeContent lineContent)
                {
                    return(result.ExpandWith(BoundingBox3D.FromGeometry(lineContent.Shape)));
                }
                return(result);
            });
            var expectedHeader = new ShapeFileHeader(length, shapeType, boundingBox);

            using (var stream = new MemoryStream())
            {
                using (var sut = new ShapeBinaryWriter(expectedHeader, new BinaryWriter(stream, Encoding.ASCII, true)))
                {
                    sut.Dispose();
                    Assert.Throws <ObjectDisposedException>(() => sut.Write(expectedRecords));
                }
            }
        }
        public void WriteOneOnDisposedInstanceHasExpectedResult()
        {
            var shapeType      = _fixture.Create <ShapeType>();
            var expectedRecord = GenerateOneRecord(shapeType);
            var length         = ShapeFileHeader.Length.Plus(expectedRecord.Length);
            var boundingBox    = BoundingBox3D.Empty;

            if (expectedRecord.Content is PointShapeContent pointContent)
            {
                boundingBox = BoundingBox3D.FromGeometry(pointContent.Shape);
            }
            if (expectedRecord.Content is PolyLineMShapeContent lineContent)
            {
                boundingBox = BoundingBox3D.FromGeometry(lineContent.Shape);
            }
            var expectedHeader = new ShapeFileHeader(length, shapeType, boundingBox);

            using (var stream = new MemoryStream())
            {
                using (var sut = new ShapeBinaryWriter(expectedHeader, new BinaryWriter(stream, Encoding.ASCII, true)))
                {
                    sut.Dispose();
                    Assert.Throws <ObjectDisposedException>(() => sut.Write(expectedRecord));
                }
            }
        }
        public void DisposeHasExpectedResult()
        {
            var expectedHeader = new ShapeFileHeader(
                ShapeFileHeader.Length,
                _fixture.Create <ShapeType>(),
                BoundingBox3D.Empty
                );

            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream, Encoding.ASCII, false))
                    using (var sut = new ShapeBinaryWriter(expectedHeader, writer))
                    {
                        sut.Dispose();
                        Assert.Throws <ObjectDisposedException>(() => writer.Write(_fixture.Create <byte>()));
                    }
            }
        }