ESRI Runtime manager must be bound to to a license for a particular ArcMap product before calling ArcObjects code. Recommended to do this in TestFixtureSetup Sub:
Dim bound As Boolean = ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop)
The AoInitialize Interface is the starting point for developers to initialize each application with a suitable license(s). Recommend to create a class level variable and initialize it in TestFixtureSetup Sub:
m_ao = New ESRI.ArcGIS.esriSystem.AoInitialize()
m_ao.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcInfo)
If you need a handle to the IApplication interface, one can be created. Recommend that it be a class-level variable shared among tests for efficiency.
If m_application Is Nothing Then
Dim doc As IDocument = New ESRI.ArcGIS.ArcMapUI.MxDocumentClass
m_application = doc.Parent
m_application.Visible = True
End If
Don't forget to free-up resources! Recommend using the TestFixtureTeardown sub. Shutting down the AoInitialize interface should always be the last ArcObjects call:
m_application.Shutdown()
End If
m_ao.Shutdown()
If m_application IsNot Nothing Then
Dim docDirtyFlag As IDocumentDirty2 = DirectCast(m_application.Document, IDocumentDirty2)
docDirtyFlag.SetClean()