6

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?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
megadrofan
  • 909
  • 4
  • 14
  • Just curious, are you using a unit testing framework and if so which one? Are you mocking ArcObjects? – blah238 May 01 '12 at 22:05
  • 1
    Using standard VS2010 testing framework. I'm not mocking AO, using ArcMap automation & PGDB. Later in my project, I plan to fascade AO with custom abstract API based on OGC Simple Feature. Then it will be more realistic to use mocking. – megadrofan May 01 '12 at 22:50

1 Answers1

7

Adding this line fixes the issue

ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Desktop);
megadrofan
  • 909
  • 4
  • 14