public void TestNonEqualCoordinatesTextFieldsBothXYJustBelowTolerance() { var featureClass = new FeatureClassMock(1, "Fc", esriGeometryType.esriGeometryPoint); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameX, 50)); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameY, 50)); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameZ, 50)); // create point feature const double x = 2600000.12345; const double y = 1200000.12345; IFeature feature = CreateFeature( featureClass, x, string.Format(_cultureInfo, "{0:N3}", x + 0.9 * _xyTolerance), y, string.Format(_cultureInfo, "{0:N3}", y - 0.9 * _xyTolerance), z: 100, zFieldValue: "100"); var test = new QaValidCoordinateFields(featureClass, _fieldNameX, _fieldNameY, _fieldNameZ, _xyTolerance, _zTolerance, _culture); var runner = new QaTestRunner(test); runner.Execute(feature); AssertUtils.OneError(runner, "ValidCoordinateFields.XYFieldCoordinatesTooFarFromShape"); }
private static IEnumerable <IField> CreateAttributeFields( [NotNull] IIssueStatisticsTableFieldNames fieldNames) { yield return(FieldUtils.CreateOIDField()); yield return(FieldUtils.CreateTextField(fieldNames.IssueDescriptionField, 4000)); yield return(FieldUtils.CreateTextField(fieldNames.IssueCodeField, 255)); yield return(FieldUtils.CreateTextField(fieldNames.IssueCodeDescriptionField, 500)); yield return(FieldUtils.CreateTextField(fieldNames.QualityConditionField, 255)); yield return (FieldUtils.CreateTextField(fieldNames.QualityConditionDescriptionField, 4000)); yield return(FieldUtils.CreateTextField(fieldNames.TestNameField, 255)); yield return(FieldUtils.CreateTextField(fieldNames.TestDescriptionField, 4000)); yield return(FieldUtils.CreateTextField(fieldNames.TestTypeField, 255)); yield return(FieldUtils.CreateTextField(fieldNames.IssueTypeField, 20)); yield return(FieldUtils.CreateTextField(fieldNames.StopConditionField, 20)); yield return(FieldUtils.CreateTextField(fieldNames.CategoriesField, 1000)); yield return(FieldUtils.CreateTextField(fieldNames.AffectedComponentField, 255)); yield return(FieldUtils.CreateTextField(fieldNames.UrlField, 1000)); yield return(FieldUtils.CreateIntegerField(fieldNames.IssueCountField)); }
private ITable CreateTable([NotNull] string name, [NotNull] string urlFieldName) { return DatasetUtils.CreateTable(_testWs, name, FieldUtils.CreateOIDField(), FieldUtils.CreateTextField(urlFieldName, 500)); }
private static IFeatureWorkspace CreateTestWorkspace( [NotNull] string fgdbName, [NotNull] string fcName, [NotNull] string tableName, [NotNull] string relClassName, [NotNull] out IFeatureClass fc, [NotNull] out ITable table, [NotNull] out IRelationshipClass rc) { IFeatureWorkspace ws = TestWorkspaceUtils.CreateTestFgdbWorkspace(fgdbName); ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); fc = DatasetUtils.CreateSimpleFeatureClass( ws, fcName, null, FieldUtils.CreateOIDField(), FieldUtils.CreateIntegerField("FKEY"), FieldUtils.CreateShapeField( "SHAPE", esriGeometryType.esriGeometryPoint, sref, 1000)); table = DatasetUtils.CreateTable(ws, tableName, FieldUtils.CreateOIDField(), FieldUtils.CreateTextField("TEXT", 100)); rc = TestWorkspaceUtils.CreateSimple1NRelationship( ws, relClassName, table, (ITable)fc, table.OIDFieldName, "FKEY"); return(ws); }
public void MissingPrefix() { IDomain domain1 = DomainUtils.AddDomain(TestWorkspace, CreateCVDomain("PRE_FIELD1")); IDomain domain2 = DomainUtils.AddDomain(TestWorkspace, CreateRangeDomain("FIELD2")); IField field1 = FieldUtils.CreateField("FIELD1", esriFieldType.esriFieldTypeInteger); IField field2 = FieldUtils.CreateField("FIELD2", esriFieldType.esriFieldTypeInteger); IField field3 = FieldUtils.CreateTextField("FIELD3", 20); ((IFieldEdit)field1).Domain_2 = domain1; ((IFieldEdit)field2).Domain_2 = domain2; ITable table = DatasetUtils.CreateTable(TestWorkspace, MethodBase.GetCurrentMethod().Name, FieldUtils.CreateOIDField(), field1, field2, field3); const int maxLength = 10; const bool mustContainFieldName = true; var runner = new QaTestRunner( new QaSchemaFieldDomainNames(table, "PRE_", maxLength, mustContainFieldName, ExpectedCase.AllUpper)); runner.Execute(); Assert.AreEqual(1, runner.Errors.Count); }
public void CanCheckOnlyDistinctUrls() { const string urlRoot = "http://localhost:8080/"; const string urlInfixExisting = "test/"; const string existingPrefix = urlRoot + urlInfixExisting; const string helloWorldHtml = "hello_world.html"; const string urlFieldName = "URL_SUFFIX"; var objectClass = new ObjectClassMock(1, "testtable"); objectClass.AddField(FieldUtils.CreateTextField(urlFieldName, 500)); int urlFieldIndex = objectClass.FindField(urlFieldName); Assert.IsTrue(urlFieldIndex >= 0); IObject rowWithExistingUrl = CreateRow(objectClass, 1, urlFieldIndex, helloWorldHtml); string urlExpression = $"'{existingPrefix}' + [{urlFieldName}]"; var errorCount = 0; using (var webServer = new WebServer(SendHeadResponse, existingPrefix)) { webServer.Run(); var test = new QaValidUrls(objectClass, urlExpression); var runner = new QaTestRunner(test); errorCount += runner.Execute(rowWithExistingUrl); errorCount += runner.Execute(rowWithExistingUrl); errorCount += runner.Execute(rowWithExistingUrl); } Assert.AreEqual(0, errorCount); Assert.AreEqual(1, _webRequestCounts); }
public void TestEqualCoordinatesTextFields() { var featureClass = new FeatureClassMock(1, "Fc", esriGeometryType.esriGeometryPoint); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameX, 50)); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameY, 50)); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameZ, 50)); // create point feature const double x = 2600000.12345; const double y = 1200000.12345; const double z = 500.12345; IFeature feature = CreateFeature( featureClass, x, string.Format(_cultureInfo, "{0:N3}", x), y, string.Format(_cultureInfo, "{0:N3}", y), z, string.Format(_cultureInfo, "{0:N3}", z)); var test = new QaValidCoordinateFields(featureClass, _fieldNameX, _fieldNameY, _fieldNameZ, _xyTolerance, _zTolerance, _culture); var runner = new QaTestRunner(test); runner.Execute(feature); Assert.AreEqual(0, runner.Errors.Count); }
private static void TestReferencedGuid(IFeatureWorkspace ws) { IFieldsEdit fields1 = new FieldsClass(); fields1.AddField(FieldUtils.CreateOIDField()); fields1.AddField(FieldUtils.CreateField("Pk", esriFieldType.esriFieldTypeGUID)); ITable tbl1 = DatasetUtils.CreateTable(ws, "TestReferencedGuid1", null, fields1); IFieldsEdit fields2 = new FieldsClass(); fields2.AddField(FieldUtils.CreateOIDField()); fields2.AddField(FieldUtils.CreateTextField("Fk", 50)); ITable tbl2 = DatasetUtils.CreateTable(ws, "TestReferencedGuid2", null, fields2); IFieldsEdit fields3 = new FieldsClass(); fields3.AddField(FieldUtils.CreateOIDField()); fields3.AddField(FieldUtils.CreateField("Fk", esriFieldType.esriFieldTypeGUID)); ITable tbl3 = DatasetUtils.CreateTable(ws, "TestReferencedGuid3", null, fields3); // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); for (int i = 0; i < 5; i++) { Guid guid = Guid.NewGuid(); CreateRow(tbl1, guid.ToString("B")); if (i % 2 == 0) { CreateRow(tbl2, guid.ToString()); } else { CreateRow(tbl3, guid.ToString("B")); } } var test = new QaUnreferencedRows(tbl1, new[] { tbl2, tbl3 }, new[] { "pk,fk", "pk,fk" }); using (var r = new QaTestRunner(test)) { r.Execute(); Assert.AreEqual(0, r.Errors.Count); } var container = new QaContainerTestRunner(10000, test); container.Execute(); Assert.AreEqual(0, container.Errors.Count); }
public void Duplicates() { IDomain domain1 = DomainUtils.AddDomain(_workspace, DomainUtils.CreateCodedValueDomain( "DOM_FIELD1", esriFieldType.esriFieldTypeInteger, "Description of DOM_FIELD1", new CodedValue(1, "Value 1"), new CodedValue(2, "Value 2"))); IDomain domain2 = DomainUtils.AddDomain(_workspace, DomainUtils.CreateCodedValueDomain( "DOM_FIELD2", esriFieldType.esriFieldTypeInteger, "Description of DOM_FIELD2", new CodedValue(1, "Value 1"), new CodedValue(2, "Value 2"))); // domain (not used in table) with duplicate name DomainUtils.AddDomain(_workspace, DomainUtils.CreateCodedValueDomain("DOM_FIELD3", esriFieldType .esriFieldTypeInteger, "Description of DOM_FIELD2", new CodedValue(1, "Value 1"), new CodedValue(2, "Value 2"))); DomainUtils.AddDomain(_workspace, DomainUtils.CreateRangeDomain("DOM_FIELD4", esriFieldType.esriFieldTypeInteger, 0, 100, "Description of DOM_FIELD2")); IField field1 = FieldUtils.CreateField("FIELD1", esriFieldType.esriFieldTypeInteger); IField field2 = FieldUtils.CreateField("FIELD2", esriFieldType.esriFieldTypeInteger); IField field3 = FieldUtils.CreateTextField("FIELD3", 20); ((IFieldEdit)field1).Domain_2 = domain1; ((IFieldEdit)field2).Domain_2 = domain2; ITable table = DatasetUtils.CreateTable(_workspace, MethodBase.GetCurrentMethod().Name, FieldUtils.CreateOIDField(), field1, field2, field3); const int maxLength = 25; const bool noDuplicates = true; var runner = new QaTestRunner(new QaSchemaFieldDomainDescriptions(table, maxLength, noDuplicates, null)); runner.Execute(); Assert.AreEqual(1, runner.Errors.Count); }
private static IEnumerable <IField> CreateFields() { yield return(FieldUtils.CreateOIDField()); yield return(FieldUtils.CreateDoubleField(_doubleFieldName)); yield return(FieldUtils.CreateDateField(_dateFieldName)); yield return(FieldUtils.CreateTextField(_textFieldName, 500)); yield return(FieldUtils.CreateTextField(_stateFieldName, 2)); }
private static ObjectClassMock CreateObjectClass([NotNull] string textFieldName, out int textFieldIndex) { var result = new ObjectClassMock(1, "testtable"); result.AddField(FieldUtils.CreateTextField(textFieldName, 500)); textFieldIndex = result.FindField(textFieldName); Assert.GreaterOrEqual(textFieldIndex, 0); return(result); }
public void CanMatchRows() { const string textField1 = "Text1"; const string textField2 = "Text2"; const string textFieldBoth = "Text"; IFeatureClass fc1 = CreateFeatureClass("CanMatchRows_fc1", esriGeometryType.esriGeometryPolygon, FieldUtils.CreateTextField(textField1, 1), FieldUtils.CreateTextField(textFieldBoth, 1)); IFeatureClass fc2 = CreateFeatureClass("CanMatchRows_fc2", esriGeometryType.esriGeometryPolygon, FieldUtils.CreateTextField(textFieldBoth, 1), FieldUtils.CreateTextField(textField2, 1)); const bool caseSensitive = true; MultiTableView view = TableViewFactory.Create(new[] { (ITable)fc1, (ITable)fc2 }, new[] { "G1", "G2" }, "G1.TEXT1 = G2.TEXT2 AND G1.Text = 'x' AND G2.Text = 'y'", caseSensitive); IFeature f1A = fc1.CreateFeature(); f1A.Value[fc1.FindField(textField1)] = "A"; f1A.Value[fc1.FindField(textFieldBoth)] = "x"; f1A.Store(); IFeature f2A = fc2.CreateFeature(); f2A.Value[fc2.FindField(textField2)] = "A"; f2A.Value[fc2.FindField(textFieldBoth)] = "y"; f2A.Store(); Assert.IsTrue(view.MatchesConstraint(f1A, f2A)); Assert.AreEqual("G1.TEXT1 = 'A'; G2.TEXT2 = 'A'; G1.TEXT = 'x'; G2.TEXT = 'y'", view.ToString(f1A, f2A)); IFeature f1B = fc1.CreateFeature(); f1B.Value[fc1.FindField(textField1)] = "b"; f1B.Value[fc1.FindField(textFieldBoth)] = "x"; f1B.Store(); IFeature f2B = fc2.CreateFeature(); f2B.Value[fc2.FindField(textField2)] = "B"; // different case --> no match f2B.Value[fc2.FindField(textFieldBoth)] = "y"; f2B.Store(); Assert.IsFalse(view.MatchesConstraint(f1B, f2B)); Assert.AreEqual("G1.TEXT1 = 'b'; G2.TEXT2 = 'B'; G1.TEXT = 'x'; G2.TEXT = 'y'", view.ToString(f1B, f2B)); }
private IFeatureClass CreateFeatureClass([NotNull] string name, esriGeometryType geometryType) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", geometryType, _spatialReference, 1000)); fields.AddField(FieldUtils.CreateTextField(_textFieldName, 200)); return(DatasetUtils.CreateSimpleFeatureClass( _testWs, name, fields)); }
private static void TestGroupContraints(IFeatureWorkspace ws) { ITable tbl = DatasetUtils.CreateTable(ws, "TestGroupContraints", FieldUtils.CreateOIDField(), FieldUtils.CreateTextField("Kostenstelle", 20)); // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); IRow row1 = tbl.CreateRow(); row1.set_Value(1, "123456-10"); row1.Store(); IRow row2 = tbl.CreateRow(); row2.set_Value(1, "123456-11"); row2.Store(); IRow row3 = tbl.CreateRow(); row3.set_Value(1, "123456-11"); row3.Store(); IRow row4 = tbl.CreateRow(); row4.set_Value(1, "023456-10"); row4.Store(); const bool limitToTestedRows = false; var test = new QaGroupConstraints(tbl, "IIF(LEN(Kostenstelle) >=6, SUBSTRING(Kostenstelle, 1, 6), '')", "SUBSTRING(Kostenstelle, 8, 9)", 1, limitToTestedRows); using (var runner = new QaTestRunner(test)) { runner.Execute(); Assert.AreEqual(1, runner.Errors.Count); } var containerRunner = new QaContainerTestRunner(100, test); containerRunner.Execute(); Assert.AreEqual(1, containerRunner.Errors.Count); }
public void CanFindDanglingSimpleKey() { const string key = "KEY1"; const string fkey = "FKEY1"; ITable referencedTable = DatasetUtils.CreateTable( _workspace, string.Format("{0}_key", MethodBase.GetCurrentMethod().Name), FieldUtils.CreateOIDField(), FieldUtils.CreateIntegerField(key)); ITable referencingTable = DatasetUtils.CreateTable( _workspace, string.Format("{0}_fkey", MethodBase.GetCurrentMethod().Name), FieldUtils.CreateOIDField(), FieldUtils.CreateTextField(fkey, 10)); GdbObjectUtils.CreateRow(referencedTable, new Dictionary <string, object> { { key, 1000 } }).Store(); GdbObjectUtils.CreateRow(referencedTable, new Dictionary <string, object> { { key, 2000 } }).Store(); GdbObjectUtils.CreateRow(referencingTable, new Dictionary <string, object> { { fkey, "1000" } }).Store(); GdbObjectUtils.CreateRow(referencingTable, new Dictionary <string, object> { { fkey, "2000" } }).Store(); // dangling reference: GdbObjectUtils.CreateRow(referencingTable, new Dictionary <string, object> { { fkey, "3000" } }).Store(); var runner = new QaTestRunner( new QaForeignKey(referencingTable, fkey, referencedTable, key)); runner.Execute(); Assert.AreEqual(1, runner.Errors.Count); }
public void CanHandleHttpAndSimpleFieldExpression() { const string urlFieldName = "URL"; const string urlRoot = "http://localhost:8080/"; const string urlInfixExisting = "test/"; const string urlInfixNotExisting = "doesnotexist/"; const string existingPrefix = urlRoot + urlInfixExisting; var objectClass = new ObjectClassMock(1, "testtable"); objectClass.AddField(FieldUtils.CreateTextField(urlFieldName, 500)); int urlFieldIndex = objectClass.FindField(urlFieldName); Assert.IsTrue(urlFieldIndex >= 0); // ok as long as prefix matches: const string urlExistingPage = urlRoot + urlInfixExisting + "pagexy.html"; // not ok since prefix does not match: const string urlNonExistingPage = urlRoot + urlInfixNotExisting + "doesnotexist.html"; IObject rowWithExistingUrl = CreateRow(objectClass, 1, urlFieldIndex, urlExistingPage); IObject rowWithNonExistingUrl = CreateRow(objectClass, 2, urlFieldIndex, urlNonExistingPage); IObject rowWithNullUrl = CreateRow(objectClass, 2, urlFieldIndex, null); // the expression contains no blanks - this checks for correct tokenization string urlExpression = $"TRIM({urlFieldName})"; var errorCount = 0; using (var webServer = new WebServer(SendHeadResponse, existingPrefix)) { webServer.Run(); var test = new QaValidUrls(objectClass, urlExpression); var runner = new QaTestRunner(test); errorCount += runner.Execute(rowWithExistingUrl); errorCount += runner.Execute(rowWithNonExistingUrl); errorCount += runner.Execute(rowWithNullUrl); } Assert.AreEqual(1, errorCount); }
public void TestExcludedFields() { IFeatureWorkspace initTestWs = _testWs; try { _testWs = TestWorkspaceUtils.CreateInMemoryWorkspace("QaRegularExpression"); IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateIntegerField(_fkFieldName)); fields.AddField(FieldUtils.CreateTextField(_textFieldName, 200)); fields.AddField(FieldUtils.CreateTextField(_textFieldName2, 200)); const string tableName = "RegEx_table_excluded"; ITable table = TestWorkspaceUtils.CreateSimpleTable(_testWs, tableName, fields); ((IWorkspaceEdit)_testWs).StartEditing(false); AddRow(table, textFieldValue: "A", textFieldValue2: "X"); AddRow(table, textFieldValue: "B", textFieldValue2: "X"); AddRow(table, textFieldValue: "A", textFieldValue2: "X"); ((IWorkspaceEdit)_testWs).StopEditing(true); var test = new QaRegularExpression(table, "A", _textFieldName2) { FieldListType = FieldListType.IgnoredFields }; IList <QaError> errors = Run(test, 1000); AssertErrors(1, errors); IList <InvolvedRow> involvedRows = errors[0].InvolvedRows; Assert.AreEqual(1, involvedRows.Count); Assert.AreEqual($"{_textFieldName}", errors[0].AffectedComponent); Assert.AreEqual("RegularExpression.FieldValueDoesNotMatchRegularExpression", errors[0].IssueCode?.ID); } finally { _testWs = initTestWs; } }
private IFeatureClass CreateFeatureClass(string name, esriGeometryType geometryType) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", geometryType, _spatialReference, 1000)); fields.AddField(FieldUtils.CreateTextField(_stateIdFieldName, 100)); fields.AddField(FieldUtils.CreateTextField(_textFieldName, 200)); fields.AddField(FieldUtils.CreateDoubleField(_doubleFieldName)); fields.AddField(FieldUtils.CreateDateField(_dateFieldName)); return(DatasetUtils.CreateSimpleFeatureClass( _featureWorkspace, name, fields)); }
public void TestNonEqualCoordinatesTextFieldsEqualY() { var featureClass = new FeatureClassMock(1, "Fc", esriGeometryType.esriGeometryPoint); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameX, 50)); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameY, 50)); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameZ, 50)); // create point feature const double x = 2600000.12345; const double y = 1200000.12345; const double z = 500.12345; IFeature feature = CreateFeature( featureClass, x, string.Format(_cultureInfo, "{0:N3}", x + 1.01 * _xyTolerance), y, string.Format(_cultureInfo, "{0:N3}", y), z, string.Format(_cultureInfo, "{0:N3}", z + 1.01 * _zTolerance)); var test = new QaValidCoordinateFields(featureClass, _fieldNameX, _fieldNameY, _fieldNameZ, _xyTolerance, _zTolerance, _culture); var runner = new QaTestRunner(test); runner.Execute(feature); Assert.AreEqual(2, runner.Errors.Count); QaError xyError = runner.Errors[0]; IssueCode xyIssueCode = xyError.IssueCode; Assert.IsNotNull(xyIssueCode); Assert.AreEqual("ValidCoordinateFields.XYFieldCoordinateValueTooFarFromShape", xyIssueCode.ID); QaError zError = runner.Errors[1]; IssueCode zIssueCode = zError.IssueCode; Assert.IsNotNull(zIssueCode); Assert.AreEqual("ValidCoordinateFields.ZFieldCoordinateTooFarFromShape", zIssueCode.ID); }
public void TooLong() { ITable table = DatasetUtils.CreateTable( _workspace, MethodBase.GetCurrentMethod().Name, FieldUtils.CreateOIDField(), FieldUtils.CreateTextField("FIELD1", 10), FieldUtils.CreateTextField("FIELD2_1234", 10), FieldUtils.CreateTextField("FIELD3", 10)); const int maxLength = 10; const int uniqueLength = 6; var runner = new QaTestRunner( new QaSchemaFieldNames(table, maxLength, ExpectedCase.AllUpper, uniqueLength)); runner.Execute(); Assert.AreEqual(1, runner.Errors.Count); }
public void InvalidCaseExpectedNotAllLower() { ITable table = DatasetUtils.CreateTable( _workspace, MethodBase.GetCurrentMethod().Name, FieldUtils.CreateOIDField(), FieldUtils.CreateTextField("FIELD1", 10), FieldUtils.CreateTextField("field2", 10), FieldUtils.CreateTextField("Field3", 10)); const int maxLength = 15; const int uniqueLength = 6; var runner = new QaTestRunner( new QaSchemaFieldNames(table, maxLength, ExpectedCase.NotAllLower, uniqueLength)); runner.Execute(); Assert.AreEqual(1, runner.Errors.Count); }
public void AllValid() { ITable table = DatasetUtils.CreateTable( _workspace, MethodBase.GetCurrentMethod().Name, FieldUtils.CreateOIDField("OBJECTID", "Object ID"), FieldUtils.CreateTextField("FIELD1", 10, "Field 1"), FieldUtils.CreateTextField("FIELD2", 10, "Field 2"), FieldUtils.CreateTextField("FIELD3", 10, "Field 3")); const bool requireUniqueAliasNames = true; const bool allowCustomSystemFieldAlias = true; var runner = new QaTestRunner( new QaSchemaFieldAliases(table, 30, ExpectedCase.Mixed, requireUniqueAliasNames, allowCustomSystemFieldAlias)); runner.Execute(); NoErrors(runner.Errors); }
public void InvalidCaseExpectedAllLower() { ITable table = DatasetUtils.CreateTable( _workspace, MethodBase.GetCurrentMethod().Name, FieldUtils.CreateOIDField("OBJECTID", "Object ID"), FieldUtils.CreateTextField("FIELD1", 10, "Field 1"), FieldUtils.CreateTextField("FIELD2", 10, "FIELD 2"), FieldUtils.CreateTextField("FIELD3", 10, "field 3")); const bool requireUnique = true; const bool allowCustomSystemFieldAlias = true; var runner = new QaTestRunner( new QaSchemaFieldAliases(table, 30, ExpectedCase.AllLower, requireUnique, allowCustomSystemFieldAlias)); runner.Execute(); Assert.AreEqual(3, runner.Errors.Count); }
public void NonUnique() { ITable table = DatasetUtils.CreateTable( _workspace, MethodBase.GetCurrentMethod().Name, FieldUtils.CreateOIDField(), FieldUtils.CreateTextField("FIELD11", 10), FieldUtils.CreateTextField("FIELD12", 10), FieldUtils.CreateTextField("FIELD13", 10), FieldUtils.CreateTextField("FIELD4", 10)); const int maxLength = 15; const int uniqueLength = 6; var runner = new QaTestRunner( new QaSchemaFieldNames(table, maxLength, ExpectedCase.AllUpper, uniqueLength)); runner.Execute(); // all non-unique fields are reported in one error Assert.AreEqual(1, runner.Errors.Count); }
public void AllValid() { IDomain domain1 = DomainUtils.AddDomain(_workspace, DomainUtils.CreateCodedValueDomain( "DOM_FIELD1", esriFieldType.esriFieldTypeInteger, new CodedValue(1, "Value 1"), new CodedValue(2, "Value 2"))); IDomain domain2 = DomainUtils.AddDomain(_workspace, DomainUtils.CreateCodedValueDomain( "DOM_FIELD2", esriFieldType.esriFieldTypeInteger, new CodedValue(1, "Value 1"), new CodedValue(2, "Value 2"))); IField field1 = FieldUtils.CreateField("FIELD1", esriFieldType.esriFieldTypeInteger); IField field2 = FieldUtils.CreateField("FIELD2", esriFieldType.esriFieldTypeInteger); IField field3 = FieldUtils.CreateTextField("FIELD3", 20); ((IFieldEdit)field1).Domain_2 = domain1; ((IFieldEdit)field2).Domain_2 = domain2; ITable table = DatasetUtils.CreateTable(_workspace, MethodBase.GetCurrentMethod().Name, FieldUtils.CreateOIDField(), field1, field2, field3); const int maxLength = 10; const int minimumValueCount = 1; const int minimumNonEqualNameValueCount = 1; const bool allowEmptyName = false; var runner = new QaTestRunner(new QaSchemaFieldDomainCodedValues( table, maxLength, UniqueStringsConstraint.UniqueAnyCase, minimumValueCount, minimumNonEqualNameValueCount, allowEmptyName)); runner.Execute(); Assert.AreEqual(0, runner.Errors.Count); }
public void Missing() { ITable table = DatasetUtils.CreateTable( _workspace, MethodBase.GetCurrentMethod().Name, FieldUtils.CreateOIDField("OBJECTID", "Object ID"), FieldUtils.CreateTextField("FIELD1", 10, "Field 1"), FieldUtils.CreateTextField("FIELD2", 10, " "), FieldUtils.CreateTextField("FIELD3", 10, "Field 3"), FieldUtils.CreateTextField("FIELD4", 10, " ")); const bool requireUniqueAliasNames = true; const bool allowCustomSystemFieldAlias = true; var runner = new QaTestRunner( new QaSchemaFieldAliases(table, 30, ExpectedCase.Mixed, requireUniqueAliasNames, allowCustomSystemFieldAlias, ExpectedStringDifference.CaseInsensitiveDifference)); runner.Execute(); Assert.AreEqual(2, runner.Errors.Count); }
public void TestUniqueStrings() { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); SpatialReferenceUtils.SetXYDomain(sref, -10000, -10000, 10000, 10000, 0.0001, 0.001); IFields fields = FieldUtils.CreateFields( FieldUtils.CreateOIDField(), FieldUtils.CreateTextField("Unique", 100), FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPoint, sref, 1000)); IFeatureClass featureClass = DatasetUtils.CreateSimpleFeatureClass(_pgdbWorkspace, "TestUniqueStrings", fields); for (var i = 0; i < 10; i++) { IFeature feature = featureClass.CreateFeature(); feature.set_Value(1, string.Format("A'{0}{1}", i, "\"")); feature.Shape = GeometryFactory.CreatePoint(100, 100, sref); feature.Store(); } IEnvelope testEnvelope = GeometryFactory.CreateEnvelope(0, 0, 200, 200, sref); foreach (bool forceInMemoryTableSort in new[] { false, true }) { var test = new QaUnique((ITable)featureClass, "Unique") { ForceInMemoryTableSorting = forceInMemoryTableSort }; var runner = new QaTestRunner(test); runner.Execute(testEnvelope); AssertUtils.NoError(runner); } }
public void TestInvalidTextFieldValues() { var featureClass = new FeatureClassMock(1, "Fc", esriGeometryType.esriGeometryPoint); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameX, 50)); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameY, 50)); featureClass.AddField(FieldUtils.CreateTextField(_fieldNameZ, 50)); // create point feature const double x = 2600000.12345; const double y = 1200000.12345; const double z = 500.12345; IFeature feature = CreateFeature(featureClass, x, "a", y, "b", z, "c"); var test = new QaValidCoordinateFields(featureClass, _fieldNameX, _fieldNameY, _fieldNameZ, _xyTolerance, _zTolerance, _culture); var runner = new QaTestRunner(test); runner.Execute(feature); Assert.AreEqual(3, runner.Errors.Count); foreach (QaError error in runner.Errors) { IssueCode issueCode = error.IssueCode; Assert.IsNotNull(issueCode); Assert.AreEqual("ValidCoordinateFields.TextFieldValueIsNotNumeric", issueCode.ID); } Assert.AreEqual(_fieldNameX, runner.Errors[0].AffectedComponent); Assert.AreEqual(_fieldNameY, runner.Errors[1].AffectedComponent); Assert.AreEqual(_fieldNameZ, runner.Errors[2].AffectedComponent); }
public void CanCreateStringCodedValueDomainConstraintNotNull() { ICodedValueDomain stringCvDomain = DomainUtils.CreateCodedValueDomain( "CanCreateStringCodedValueDomainConstraintNotNull", esriFieldType.esriFieldTypeString, null, esriSplitPolicyType.esriSPTDuplicate, esriMergePolicyType.esriMPTDefaultValue, new CodedValue("a", "Value a"), new CodedValue("b", "Value b"), new CodedValue("c", "Value c")); DomainUtils.AddDomain(_testWs, stringCvDomain); IField textField = FieldUtils.CreateTextField("TextField", 100); ((IFieldEdit)textField).Domain_2 = (IDomain)stringCvDomain; ITable table = DatasetUtils.CreateTable(_testWs, "CanCreateStringCodedValueDomainConstraintNotNull", FieldUtils.CreateOIDField(), textField); List <ConstraintNode> constraints = GdbConstraintUtils.GetGdbConstraints( table, allowNullForCodedValueDomains: false); Assert.NotNull(constraints); foreach (ConstraintNode constraint in constraints) { Console.WriteLine(constraint); } Assert.AreEqual(2, constraints.Count); Assert.AreEqual("TextField IN ('a', 'b', 'c')", constraints[0].Condition); Assert.AreEqual("OBJECTID >= 0", constraints[1].Condition); }
private IFeatureClass CreateFeatureClass([NotNull] string name, esriGeometryType type, [NotNull] string urlFieldName) { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference ((int) esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); SpatialReferenceUtils.SetXYDomain(sref, -10000, -10000, 10000, 10000, 0.0001, 0.001); const bool mAware = false; const bool hasZ = false; IFields fields = FieldUtils.CreateFields( FieldUtils.CreateOIDField(), FieldUtils.CreateShapeField("Shape", type, sref, 1000, hasZ, mAware), FieldUtils.CreateTextField(urlFieldName, 500)); return DatasetUtils.CreateSimpleFeatureClass(_testWs, name, fields); }