private void TestFlowDirExpression(IFeatureWorkspace ws) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateField("FlowDir", esriFieldType.esriFieldTypeInteger)); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000)); IFeatureClass featureClass = DatasetUtils.CreateSimpleFeatureClass(ws, "TestFlowDirExpression", fields); // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); { IFeature row = featureClass.CreateFeature(); row.set_Value(1, 5); row.Shape = GeometryFactory.CreateLine( GeometryFactory.CreatePoint(100, 200), GeometryFactory.CreatePoint(110, 190)); row.Store(); } { IFeature row = featureClass.CreateFeature(); row.set_Value(1, 10); row.Shape = GeometryFactory.CreateLine( GeometryFactory.CreatePoint(120, 190), GeometryFactory.CreatePoint(110, 190)); row.Store(); } IPoint lastPoint; { IFeature row = featureClass.CreateFeature(); row.set_Value(1, null); row.Shape = GeometryFactory.CreateLine( GeometryFactory.CreatePoint(120, 190), GeometryFactory.CreatePoint(130, 190)); row.Store(); lastPoint = ((IPolyline)row.Shape).ToPoint; } var test = new QaFlowLogic(new[] { featureClass }, new[] { "FlowDir > 6" }); test.QaError += Test_QaError; _errorCount = 0; test.Execute(); Assert.AreEqual(1, _errorCount); Assert.AreEqual(lastPoint.X, _lastErrorPoint.X); Assert.AreEqual(lastPoint.Y, _lastErrorPoint.Y); test.QaError -= Test_QaError; var container = new TestContainer(); container.AddTest(test); container.QaError += Test_QaError; _errorCount = 0; container.Execute(); Assert.AreEqual(1, _errorCount); Assert.AreEqual(lastPoint.X, _lastErrorPoint.X); Assert.AreEqual(lastPoint.Y, _lastErrorPoint.Y); }
private void TestFlowDirMultiExpression(IFeatureWorkspace ws) { IFeatureClass fc1; { var fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateField("FlowDir", esriFieldType.esriFieldTypeInteger)); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000)); fc1 = DatasetUtils.CreateSimpleFeatureClass(ws, "TestFlowDirMultiExpression1", fields); } IFeatureClass fc2; { var fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateField("FlowDir", esriFieldType.esriFieldTypeInteger)); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000)); fc2 = DatasetUtils.CreateSimpleFeatureClass(ws, "TestFlowDirMultiExpression2", fields); } // make sure the tables are known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); { IFeature row = fc1.CreateFeature(); row.set_Value(1, 5); row.Shape = GeometryFactory.CreateLine( GeometryFactory.CreatePoint(100, 200), GeometryFactory.CreatePoint(110, 190)); row.Store(); } { IFeature row = fc2.CreateFeature(); row.set_Value(1, 5); row.Shape = GeometryFactory.CreateLine( GeometryFactory.CreatePoint(120, 190), GeometryFactory.CreatePoint(110, 190)); row.Store(); } { IFeature row = fc1.CreateFeature(); row.set_Value(1, null); row.Shape = GeometryFactory.CreateLine( GeometryFactory.CreatePoint(120, 190), GeometryFactory.CreatePoint(130, 190)); row.Store(); } { var test = new QaFlowLogic( new[] { fc1, fc2 }, new[] { "FlowDir > 6", "FlowDir < 6" } // no feature fc1 will be inverted, feature of fc2 will be inverted ); test.QaError += Test_QaError; _errorCount = 0; test.Execute(); Assert.AreEqual(1, _errorCount); test.QaError -= Test_QaError; var container = new TestContainer(); container.AddTest(test); _errorCount = 0; container.QaError += Test_QaError; container.Execute(); Assert.AreEqual(1, _errorCount); } { var test = new QaFlowLogic( new[] { fc1, fc2 }, new[] { "FlowDir > 6" } // no feature will be inverted ); test.QaError += Test_QaError; _errorCount = 0; test.Execute(); Assert.AreEqual(3, _errorCount); test.QaError -= Test_QaError; var container = new TestContainer(); container.AddTest(test); container.QaError += Test_QaError; _errorCount = 0; container.Execute(); Assert.AreEqual(3, _errorCount); } }