private IGeoDataServer InitGeoDataServerFromWorkspace(IWorkspace geodatabase) { // Create the GeoDataServer and cast to the the IGeoDataServerInit interface. IGeoDataServer geoDataServer = new GeoDataServerClass(); IGeoDataServerInit geoDataServerInit = (IGeoDataServerInit)geoDataServer; // Initialize the GeoDataServer and return it. geoDataServerInit.InitWithWorkspace(geodatabase); return geoDataServer; }
[TestMethod()] //[DeploymentItem("Batch Reconcile and Post.exe")] public void InitGeoDataServerFromWorkspaceTest() { ArcSDEUtilities_Accessor target = new ArcSDEUtilities_Accessor(); IWorkspace geodatabase = (IWorkspace)iworkspacemock.MockInstance; IGeoDataServer expected = (IGeoDataServer)geodataservermock.MockInstance; IGeoDataServer actual; actual = target.InitGeoDataServerFromWorkspace(geodatabase); Assert.AreEqual(expected, actual); }
Alex,You are right. The license make me to be able to get the feature classes. But this line gave an error:public static void ClassCleanup() { fileGDB = null; m_aoInit.Shutdown(); //ERROR: COM object that has been separated from its underlying RCW cannot be used. }my m_aoInit was defined in ClassInitialize, just like yours.Vara,The Window 7 machine is 64 bit.Thanks for your help!Julie
How can I access a gdb in Unit Test method so I can get some testing feature classes to test spatial operations in my ArcObject extension project. I'm using VS 2010 with ArcGIS 10 on Window 7 machine to create a Desktop component.Right now I'm getting COMException from HRESULT: 0x80040258 when I call "workspaceFactory.OpenFromFile(path, 0)".Thanks!Julie
Private Shared m_aoInit As IAoInitialize ' ' You must initialize an ArcGIS License to test ArcObjects code ' 'Use ClassInitialize to run code before running the first test in the class <ClassInitialize()> Public Shared Sub MyClassInitialize(ByVal testContext As TestContext) ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop) m_aoInit = New AoInitialize m_aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo) End Sub 'Use ClassCleanup to run code after all tests in a class have run <ClassCleanup()> Public Shared Sub MyClassCleanup() m_aoInit.Shutdown() End Sub
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.