Exemplo n.º 1
0
        private void TestConnections(IFeatureWorkspace ws)
        {
            IFieldsEdit fields = new FieldsClass();

            fields.AddField(FieldUtils.CreateOIDField());
            fields.AddField(FieldUtils.CreateIntegerField("LineTyp", "LineTyp"));
            fields.AddField(FieldUtils.CreateShapeField(
                                "Shape", esriGeometryType.esriGeometryPolyline,
                                SpatialReferenceUtils.CreateSpatialReference
                                    ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95,
                                    true), 1000, false, false));

            IFeatureClass fc =
                DatasetUtils.CreateSimpleFeatureClass(ws, "TestConnections", fields,
                                                      null);
            IList <ITable> tbls = new[] { (ITable)fc };

            // make sure the table is known by the workspace
            ((IWorkspaceEdit)ws).StartEditing(false);
            ((IWorkspaceEdit)ws).StopEditing(true);

            {
                IFeature row = fc.CreateFeature();
                row.set_Value(1, 1);
                row.Shape =
                    CurveConstruction.StartLine(100, 100).LineTo(200, 200).Curve;
                row.Store();
            }
            {
                IFeature row = fc.CreateFeature();
                row.set_Value(1, 2);
                row.Shape =
                    CurveConstruction.StartLine(100, 100.1).LineTo(100, 200).Curve;
                row.Store();
            }

            IList <QaConnectionRule> rules = new[]
            {
                new QaConnectionRule(tbls, new[] { "LineTyp = 1" }),
                new QaConnectionRule(tbls, new[] { "LineTyp = 2" })
            };
            var test = new QaConnections(new[] { fc }, rules, 0);

            test.QaError += Test_QaError;
            _errorCount   = 0;
            test.Execute();
            Assert.AreEqual(0, _errorCount);
            test.QaError -= Test_QaError;

            var container = new TestContainer();

            container.AddTest(test);
            container.QaError += Test_QaError;
            _errorCount        = 0;
            container.Execute();
            Assert.AreEqual(0, _errorCount);
        }
Exemplo n.º 2
0
        public void TestMultipart()
        {
            IFeatureWorkspace ws = TestWorkspaceUtils.CreateInMemoryWorkspace("Testmultipart");

            IFieldsEdit fields = new FieldsClass();

            fields.AddField(FieldUtils.CreateOIDField());
            fields.AddField(FieldUtils.CreateIntegerField("LineTyp", "LineTyp"));
            fields.AddField(FieldUtils.CreateShapeField(
                                "Shape", esriGeometryType.esriGeometryPolyline,
                                SpatialReferenceUtils.CreateSpatialReference
                                    ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95,
                                    true), 1000, false, false));

            IFeatureClass fc =
                DatasetUtils.CreateSimpleFeatureClass(ws, "TestConnections", fields,
                                                      null);
            IList <ITable> tbls = new[] { (ITable)fc };

            {
                IFeature row = fc.CreateFeature();
                row.set_Value(1, 1);
                row.Shape =
                    CurveConstruction.StartLine(1, 1).LineTo(2, 2).MoveTo(3, 2).LineTo(4, 2).Curve;
                row.Store();
            }
            {
                IFeature row = fc.CreateFeature();
                row.set_Value(1, 2);
                row.Shape =
                    CurveConstruction.StartLine(1, 5).LineTo(2, 2).Curve;
                row.Store();
            }

            IList <QaConnectionRule> rules = new List <QaConnectionRule>
            {
                new QaConnectionRule(tbls, new[] { "LineTyp = 1" }),
                new QaConnectionRule(tbls, new[] { "LineTyp = 2" })
            };
            var test = new QaConnections(new[] { fc }, rules, 0);

            test.UseMultiParts = false;
            var runner = new QaContainerTestRunner(1000, test);

            Assert.AreEqual(0, runner.Execute());

            test.UseMultiParts = true;
            runner             = new QaContainerTestRunner(1000, test);
            Assert.AreEqual(1, runner.Execute());
        }