[GIS] Automating ArcMap with ArcObjects for unit testing

arcgis-license-managerarcmaparcobjects

I need to run unit tests against ArcMap extension which closely coupled with specific edit workspace and map state. When I try to initialize ArcMap 10 application with code like this:

ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
IDocument pdoc = new MxDocumentClass();
_application = pdoc.Parent;

I receive error:

The runtime application type must be specified before license initialization

Is there any workaround or better way for unit testing?

Best Answer

Adding this line fixes the issue

ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Desktop);
Related Question