Does anyone know how to mock IGeometry (e.g. using NSubstitute)? I want to use it within an ISpatialFilter, however I always get an exception on the last line of the code beyond.

COMException: The geometry property of the spatial filter is invalid. (-2147216814)

When I use a realworld-instance such as PolygonClass it works, however if I use this and afterwards do some topological operations (intersect) on them I also use real-world code which I want to avoid.

This is what I have so far:

var poly = Substitute.For<IPolygon, IGeometry>();
var filter = new SpatialFilter
    Geometry = (IGeometry)poly,
    SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
  • Maybe the geometry needs a SpatialReference
    – nef001
    Feb 16 '16 at 10:42
  • Assigned a new instance of UnknownCoordinateSystem, the error remains. However I assume the framework will automatically inject a proxy-type for ISpatialReference (as it also does for Envelope e.g). Feb 16 '16 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.