POST
|
which mocking-framework do you use Luke? So when I do AOInitialize at classinitiliaze i am rid of my problems? Apologies for the long delay in responding. Currently I'm using Rhino Mocks, but as I expand my unit/integration tests for this group of projects, I'm starting to run into a few issues (Namely with building my MSTest project on a deployment server) and am starting to contemplate switching all of that architecture up. I haven't run AOInitialize as yet. I have previously been attempting to keep as much AO logic from bleeding into my testing work as possible. Considering I'm trying to test business logic, and am often disconnected from my license server, it's beneficial for me to isolate out the AO as much as possible. I will fire up some tests with it though and get back with you.
... View more
11-09-2012
06:05 AM
|
0
|
0
|
289
|
POST
|
Thanks for the quick response! Here is where I'm at now: I was also receiving a warning that I was neglecting to address (I've currently also got a separate issue where the addin cannot access our SOA upon deployment) that was suggesting that I switch the Embed Interop Types property to false on the AO packages for the [testing] project. Once I did that I was able to at least create mock AO instances (UIDClass, IPropertySet2, IApplication). With a little bit of refactoring I am able to pass the Mock instances of UIDClass and IApplication into the method that I'm attempting to test, but I'm currently working through setting the "esriEditor.Editor" Value to my mock UIDClass correctly
public IEditor GetEditor (UID uid, IApplication app) {
IEditor editor = null;
editor = app.FindExtensionByCLSID(uid) as IEditor;
return editor;
}
[TestMethod()]
public void GetEditor_MockingTest () {
MockRepository mockrepo = new MockRepository();
PlotDocumentGeneratorClass plotter = new PlotDocumentGeneratorClass();
UID testuid = mockrepo.StrictMockWithRemoting<UIDClass>();
testuid.Value = "esriEditor.Editor";
IApplication testapp = mockrepo.StrictMock<IApplication>();
IEditor testeditor = plotter.GetEditor(testuid, testapp);
Assert.IsNotNull(testeditor);
}
... View more
08-20-2012
09:25 AM
|
0
|
0
|
289
|
POST
|
just a question, or a suggestion, but the majority of the stackexchange sites strongly encourage the inclusion of code snippets. As I'm newer to unit testing, and am still efforting to refactor an application to become more testable (ultimately, I want it to get to a TDD state) examples of how some of you have successfully used MSTest (Visual Studio's built in framework) and/or any mocking framework would be great. where I'm at currently with inclusion of mocking to my tests (again, just a snippet):
[TestMethod()]
public void GenerateNewPlotDocument_ProperlySetsQuadid () {
PlotDocumentGeneratorClass plotter = new PlotDocumentGeneratorClass();
plotter.GenerateNewPlotDocument("449a");
Assert.AreEqual("449a", plotter.quadid);
}
[TestMethod()]
public void CheckLayoutView_ReturnsIFeatureWorkspaceType () {
MockRepository mockrepo = new MockRepository();
IPlotDocument plotter = mockrepo.DynamicMock<PlotDocumentGeneratorClass>();
IFeatureWorkspace transworkspace = plotter.SetCurrentWorkspace();
Assert.IsInstanceOfType(transworkspace, typeof(ESRI.ArcGIS.Geodatabase.IFeatureWorkspace));
}
[TestMethod()]
public void GetEditor_MockingTest () {
MockRepository mockrepo = new MockRepository();
PlotDocumentGeneratorClass plotter = new PlotDocumentGeneratorClass();
UID test = mockrepo.StrictMock<UID>();
Assert.IsNotNull(test);
}
... View more
08-20-2012
05:54 AM
|
0
|
0
|
700
|
POST
|
I don't believe that this is related to the STA/MTA portion of this issue (sorry for the bump, but this looks like the most directly related Unit Testing thread across the forums) I'm getting hit by the following error every time I run into anything that initially sits in the ESRI.ArcGIS.esriSystem package (specifically UID/UIDClass and IPropertySet). This will happen regardless of whether or not I attempt to access through a mocking framework (I'm currently using Rhino Mocks): Warning: Test Run deployment issue: The assembly or module 'ESRI.DADF.Core' directly or indirectly referenced by the container 'C:\[MyArcGISAddinDeploymentDirectory]\editorassisttests.dll' was not found. I have been working through the process of refactoring as much of my code to NOT use AO as much as possible, in the expectation that I could reach a target of around 80% code coverage (unit/integration test combo). But getting IEditor and IFeatureWorkspace are kind of tough to avoid. If anyone has any guidance, I'd gladly accept all the help I can get. I'm fairly new to Unit Testing, and trying to learn it in the wild by translating java examples across to AO is a little bit of a brain drain. Below are a couple code examples of simple situations that I'm using to just verify that I can get these "things".
[TestMethod()]
public void CheckLayoutView_ReturnsIFeatureWorkspaceType () {
MockRepository mockrepo = new MockRepository();
IPlotDocument plotter = mockrepo.DynamicMock<PlotDocumentGeneratorClass>();
IFeatureWorkspace transworkspace = plotter.SetCurrentWorkspace();
Assert.IsInstanceOfType(transworkspace, typeof(ESRI.ArcGIS.Geodatabase.IFeatureWorkspace));
}
[TestMethod()]
public void GetEditor_MockingTest () {
MockRepository mockrepo = new MockRepository();
PlotDocumentGeneratorClass plotter = new PlotDocumentGeneratorClass();
UID test = mockrepo.StrictMock<UID>();
Assert.IsNotNull(test);
}
[TestMethod()]
public void GetWorkspace_ReturnsNotNull () {
PlotDocumentGeneratorClass plotter = new PlotDocumentGeneratorClass();
IFeatureWorkspace ws = plotter.GetWorkspace("LBADGEROW", "C:\\", false);
Assert.IsNotNull(ws);
}
... View more
08-20-2012
05:36 AM
|
0
|
0
|
289
|
POST
|
I still get stuck with the same ValidateAddInXMLTask error. I'm still tinkering with some configurations though. Registering the Shell.9.0.dll with the gac didn't solve my issue. I'm running into a version conflict now with the Shell dll (version I have is 10.0) from my log viewer:
*** Assembly Binder Log Entry (6/18/2012 @ 8:35:07 AM) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = CWW\LBadgerow
LOG: DisplayName = Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSBuild.exe
Calling assembly : ESRI.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/Microsoft.VisualStudio.Shell.9.0.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.VisualStudio.Shell.9.0.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Microsoft.VisualStudio.Shell.9.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
... View more
06-18-2012
04:12 AM
|
0
|
0
|
916
|
POST
|
-- it's only when TeamCity is calling that it has this odd behavior. As I've asked around with some of the other AO developers I know I am often met with the blank stare of "why would you want to use an external build tool". I was really starting to fear that trying to implement anything like this was going to brand me some kind of java developing freak.
... View more
04-23-2012
09:09 AM
|
0
|
0
|
1616
|
POST
|
I have no idea where to get the ESRI.ArcGIS.AddIns.SDK.resources.DLL from! Have you managed to track down this dll? I pulled out the "parent" ESRI.ArcGIS.AddIns.SDK.dll by reinstalling the ArcObjects .NET SDK as described in this forum thread: http://forums.arcgis.com/threads/118-Beta-10-.Net-Untrusted-component but I just went through another quick search of my file system and didn't see the .resources.dll anywhere. I'm going to keep looking though. thanks for posting your logs!
... View more
04-23-2012
09:05 AM
|
0
|
0
|
1616
|
POST
|
Did you ever get any resolution on this? I'm experiencing the exact same problem. I haven't as yet. I've worked with it for couple of days here and there, and I forwarded the error message to a friend that works in Redlands but I don't expect to hear from him for a while given the fact that they're in code freeze moving up to 10.1. I'm waiting to elevate this to an actual tech services call until I have the time to burn explaining what I'm trying to do to teir-1 support. As I hear anything I'll let you know.
... View more
03-27-2012
07:03 AM
|
0
|
0
|
1616
|
POST
|
so I'll bump myself, since every time I google this I get brought back here. The error above is actually caused by the version of msbuild I was using. When I switched to use the DOTNET Framework v4.0 I receive a new and also interesting error. Side note, I am able to build both of the WPF/ Console applications I have targeted for 10.0. C:\Program Files (x86)\MSBuild\ESRI\ESRI.ArcGIS.AddIns.targets(36,5): error MSB 4062: The "ValidateAddInXMLTask" task could not be loaded from the assembly ESR I.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc63 1e44ad86. Could not load file or assembly 'Microsoft.VisualStudio.Shell.9.0, Ve rsion=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <Usin gTask> declaration is correct, that the assembly and all its dependencies are a vailable, and that the task contains a public class that implements Microsoft.B uild.Framework.ITask. Done Building Project "c:\workspace\dotnet\watereditor10\watereditorextension.c sproj" (default targets) -- FAILED. Build FAILED. right now, I believe that the <UsingTask> that the error is referring to comes from the targets file for the Addins.SDK: <UsingTask AssemblyName="ESRI.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86" TaskName="ValidateAddInXMLTask" />
<Target Name="PrePackageArcGISAddIn">
<ValidateAddInXMLTask ContentFiles="@(AddInContent)" BuildProjectPath="$(ProjectPath)" AssemblyName="$(TargetFileName)" TargetFrameworkVersion="$(TargetFrameworkVersion)" />
</Target>
But that's where I'm stuck.
... View more
03-16-2012
11:55 AM
|
0
|
0
|
1616
|
POST
|
I am in the process of putting together a CI Server application (Jenkins) that is currently building my SOA application. I would like to add a desktop add-in that I am also working on to this server, however in order for that to happen I need to be able to build with msbuild.exe. When I try and compile my add-in project with msbuild I receive the following error (more specifically, the following comes from Jenkins, but it's the same error locally): Started by user anonymous Updating http://subversion-repo/EngineeringServices/DesktopGISUtilities/DOTNET/WaterEditorExtension At revision 1241 no change for http://subversion-repo/EngineeringServices/DesktopGISUtilities/DOTNET/WaterEditorExtension since the previous build Path To MSBuild.exe: C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe Executing command: cmd.exe /C C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe c:\workspace\dotnet\watereditor10\watereditorextension.csproj && exit %%ERRORLEVEL%% [workspace] $ cmd.exe /C C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe c:\workspace\dotnet\watereditor10\watereditorextension.csproj && exit %%ERRORLEVEL%% Microsoft (R) Build Engine Version 3.5.30729.1 [Microsoft .NET Framework, Version 2.0.50727.3623] Copyright (C) Microsoft Corporation 2007. All rights reserved. Build started 11/29/2011 11:20:08 AM. Project "c:\workspace\dotnet\watereditor10\watereditorextension.csproj" on node 0 (default targets). Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5". C:\Program Files (x86)\MSBuild\ESRI\ESRI.ArcGIS.AddIns.targets(36,5): error MSB4062: The "ValidateAddInXMLTask" task could not be loaded from the assembly ESRI.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86. Could not load file or assembly 'Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available. Done Building Project "c:\workspace\dotnet\watereditor10\watereditorextension.csproj" (default targets) -- FAILED. Build FAILED. "c:\workspace\dotnet\watereditor10\watereditorextension.csproj" (default target) (1) -> (PrePackageArcGISAddIn target) -> C:\Program Files (x86)\MSBuild\ESRI\ESRI.ArcGIS.AddIns.targets(36,5): error MSB4062: The "ValidateAddInXMLTask" task could not be loaded from the assembly ESRI.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86. Could not load file or assembly 'Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available. 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.68 Build step 'Build a Visual Studio project or solution using MSBuild.' marked build as failure Finished: FAILURE
... View more
11-29-2011
11:09 AM
|
0
|
22
|
12161
|
POST
|
this is a bit of a bump. I noticed this morning as I was working through an error that was causing my application to crash that I was left with a number of orphan SDE Connections, which led me to investigating how we should close these connections (COM Releaser is a little clunky for me). As I've been reading, it doesn't look like anyone pays any attention to this, and the API Reference for IWorkspace or IWorkspaceFactory have no methods to Close. Has anyone found a good work around?
... View more
09-28-2011
06:41 AM
|
0
|
0
|
241
|
POST
|
We dont get many questions on this so can you give us some more information on what types of edits you want to do here. Thanks[/QUOTE wrote: I don't want to hijack your thread, but when I update the geometry of my annotation, I'm losing my actual annotation (the text component). The method below is what I'm implementing here: private void ExperimentalMethod(int objectid, IFeatureLayer newlayer, IFeatureLayer existinglayer) {
IFeature newfeature = newlayer.FeatureClass.GetFeature(objectid);
IFeature existingfeature = FindNearestAnnotation(newfeature, existinglayer);
IGeometry existinggeometry = existingfeature.Shape;
IAnnotationFeature annofeat = (IAnnotationFeature)newfeature;
IElement element = annofeat.Annotation;
element.Activate(ArcMap.Document.ActiveView.ScreenDisplay);
element.Geometry = existinggeometry;
ITextElement textelement = (ITextElement)element;
ITextSymbol symbol = textelement.Symbol;
symbol.Angle = (double)existingfeature.get_Value(
existingfeature.Fields.FindField("Angle"));
symbol.Text = newfeature.get_Value(
newfeature.Fields.FindField("TextString")).ToString();
textelement.Symbol = symbol;
annofeat.Annotation = (IElement)textelement;
newfeature = (IFeature)annofeat;
newfeature.Store();
}
... View more
09-08-2011
11:28 AM
|
0
|
0
|
331
|
POST
|
awesome! Thanks for the response. That'll teach me to code without regard for maintaining it down the road.
... View more
06-16-2011
05:38 AM
|
0
|
0
|
615
|
POST
|
so any advice on this error: Failed InitGeoDataServerFromWorkspaceTest TestPostReconcile Test method TestPostReconcile.ArcSDEUtilitiesTest.InitGeoDataServerFromWorkspaceTest threw exception: System.InvalidCastException: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). The code: 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;
} The test: [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);
} the initialize logic helped clear my first hurdle with this. thanks much for that. I'm just getting tripped up on how this all plays out, I'm brand new to unit testing (been trying to implement for about a year now, just getting to it).
... View more
06-15-2011
09:13 AM
|
0
|
0
|
615
|
POST
|
I'm using a combination of NUnit and the standard Unit Testing framework provided by Visual Studio 2008. As for how much work it's making for me, it's hard to say. I'm new to unit testing, and it feels like any time I make an arcobject call within a method that it's blowing up my test with the following error, so I'm starting to get a little worried that I'm going to have to refactor my entire code base so that I can pass every call to an arcobject as a parameter so that I can mock it for my tests. Error 1 Test 'TestPostReconcile.ArcSDEUtilitiesTest.InitGeodataServerFromFileTest' failed: Test method TestPostReconcile.ArcSDEUtilitiesTest.InitGeodataServerFromFileTest threw exception: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {A61F2A53-878A-4703-AB50-50FC0B8FEEEF} failed due to the following error: 80040111.. at AutomatedReconcileCsharp.ArcSDEUtilities_Accessor.InitGeodataServerFromFile(String path) at TestPostReconcile.ArcSDEUtilitiesTest.InitGeodataServerFromFileTest() in C:\Documents and Settings\lbadgerow\My Documents\Visual Studio 2008\Projects\BatchReconcilePost\TestPostReconcile\ArcSDEUtilitiesTest.cs:line 81 C:\Documents and Settings\lbadgerow\My Documents\Visual Studio 2008\Projects\BatchReconcilePost\TestPostReconcile\ArcSDEUtilitiesTest.cs 81
... View more
06-15-2011
08:45 AM
|
0
|
3
|
755
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|