Why does it work?
You know that question?
For a long long time I had one test in DeploymentWorkspaceUtils that just didn't want to pass, it was called:
Deployment_RenameLayer_GeometryPolylineOldLayerHasData_GetData
The test was simple:
1. Create a layer of type polyline
2. Put a feature in the layer
3. Rename the layer
4. Get the data back from the renamed layer
I had two more tests identical to this test but with point and polygon data.
But in the part of renaming the layer I got the following error:
System.Runtime.InteropServices.COMException: The number of points is less than required for feature
Today I had some time and got back to this test, I thought to myself that since the error is of the number of points I figured the trouble was with reading the data.
My second thought was that I didn't clone the geometry returned into my entity, I placed a breakpoint in my entity and waited and waited some more…
Then I tried to slam my head to the wall – I didn't use entity in rename since I didn't have any entity.
I looked again and in the rename I simply used a List<IFeature>, than I thought about the most annoying Boolean in IWorkspace – IsRecycling mine was of course set to true.
Now the real question is why didn't the Polygon fail as well???
Then I thought to myself maybe the geometry in the DB for the polyline is not simplified lets try to simplify it! The result was the same old error => The number of points is less than required for feature
So I changed my test to be with two features in step 2 and added an assert that the geometry length (for IPolygon and IPolyline) is greater than zero. For the point I added an assert on the X and Y of the point.
And still the point and the polygon tests pass, the polygon's length was ~40 which is to say greater than zero, WHY???
I decided to add a test that verifies that the 2 entities are different and now the point and polygon tests fail and the polyline test (still) throws an exception.
In the end I decided to just fix the damn test and try not to think logically with ESRI…