protected override IList <ITest> CreateTestInstances(object[] args) { Assert.AreEqual(3, args.Length, "Unexpected argument count"); var table = (ITable)args[0]; var allowNullValuesForCodedValueDomains = (bool)args[1]; var allowNullValuesForRangeDomains = (bool)args[2]; var result = new List <ITest>(2); IList <ConstraintNode> nodes = GdbConstraintUtils.GetGdbConstraints( table, allowNullValuesForCodedValueDomains, allowNullValuesForRangeDomains); if (nodes.Count > 0) { // add test for subtypes/domains result.Add(new QaConstraint(table, nodes, errorDescriptionVersion: 1)); } IList <string> fields = GdbConstraintUtils.GetUuidFields(table); if (fields.Count > 0) { var validUuidTest = new QaValue(table, fields); result.Add(validUuidTest); } return(result); }
public void CanCreateIntegerRangeDomainConstraintNotNull() { IRangeDomain integerRangeDomain = DomainUtils.CreateRangeDomain( "CanCreateIntegerRangeDomainConstraintNotNull", esriFieldType.esriFieldTypeInteger, 0, 100); DomainUtils.AddDomain(_testWs, integerRangeDomain); IField integerField = FieldUtils.CreateIntegerField("IntegerField"); ((IFieldEdit)integerField).Domain_2 = (IDomain)integerRangeDomain; ITable table = DatasetUtils.CreateTable(_testWs, "CanCreateIntegerRangeDomainConstraintNotNull", FieldUtils.CreateOIDField(), integerField); List <ConstraintNode> constraints = GdbConstraintUtils.GetGdbConstraints( table, allowNullForRangeDomains: false); Assert.NotNull(constraints); foreach (ConstraintNode constraint in constraints) { Console.WriteLine(constraint); } Assert.AreEqual(2, constraints.Count); Assert.AreEqual("IntegerField >= 0 AND IntegerField <= 100", constraints[0].Condition); Assert.AreEqual("OBJECTID >= 0", constraints[1].Condition); }
public void CanCreateDoubleCodedValueDomainConstraint() { ICodedValueDomain doubleCvDomain = DomainUtils.CreateCodedValueDomain( "CanCreateDoubleCodedValueDomainConstraint", esriFieldType.esriFieldTypeDouble, null, esriSplitPolicyType.esriSPTDuplicate, esriMergePolicyType.esriMPTDefaultValue, new CodedValue(1.00000000001, "Value 1.00000000001"), new CodedValue(2.00000000002, "Value 2.00000000002"), new CodedValue(3.00000000003, "Value 3.00000000003")); DomainUtils.AddDomain(_testWs, doubleCvDomain); IField doubleField = FieldUtils.CreateDoubleField("DoubleField"); ((IFieldEdit)doubleField).Domain_2 = (IDomain)doubleCvDomain; ITable table = DatasetUtils.CreateTable(_testWs, "CanCreateDoubleCodedValueDomainConstraint", FieldUtils.CreateOIDField(), doubleField); List <ConstraintNode> constraints = GdbConstraintUtils.GetGdbConstraints(table); Assert.NotNull(constraints); foreach (ConstraintNode constraint in constraints) { Console.WriteLine(constraint); } Assert.AreEqual(2, constraints.Count); Assert.AreEqual( "DoubleField IS NULL OR (Convert(DoubleField, 'System.Single') IN " + "(Convert(1.00000000001, 'System.Single'), " + "Convert(2.00000000002, 'System.Single'), " + "Convert(3.00000000003, 'System.Single')))", constraints[0].Condition); Assert.AreEqual("OBJECTID >= 0", constraints[1].Condition); }
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); }
public void CanCreateIntegerCodedValueDomainConstraint() { ICodedValueDomain integerCvDomain = DomainUtils.CreateCodedValueDomain( "CanCreateIntegerCodedValueDomainConstraint", esriFieldType.esriFieldTypeInteger, null, esriSplitPolicyType.esriSPTDuplicate, esriMergePolicyType.esriMPTDefaultValue, new CodedValue(1, "Value 1"), new CodedValue(2, "Value 2"), new CodedValue(3, "Value 3")); DomainUtils.AddDomain(_testWs, integerCvDomain); IField integerField = FieldUtils.CreateIntegerField("IntegerField"); ((IFieldEdit)integerField).Domain_2 = (IDomain)integerCvDomain; ITable table = DatasetUtils.CreateTable(_testWs, "CanCreateIntegerCodedValueDomainConstraint", FieldUtils.CreateOIDField(), integerField); List <ConstraintNode> constraints = GdbConstraintUtils.GetGdbConstraints(table); Assert.NotNull(constraints); foreach (ConstraintNode constraint in constraints) { Console.WriteLine(constraint); } Assert.AreEqual(2, constraints.Count); Assert.AreEqual("IntegerField IS NULL OR (IntegerField IN (1, 2, 3))", constraints[0].Condition); Assert.AreEqual("OBJECTID >= 0", constraints[1].Condition); }
public void CanCreateDateTimeRangeDomainConstraintNotNull() { IRangeDomain dateRangeDomain = DomainUtils.CreateRangeDomain( "CanCreateDateTimeRangeDomainConstraintNotNull", esriFieldType.esriFieldTypeDate, new DateTime(2011, 12, 31), new DateTime(2012, 1, 31, 23, 55, 59)); DomainUtils.AddDomain(_testWs, dateRangeDomain); IField dateField = FieldUtils.CreateDateField("DateField"); ((IFieldEdit)dateField).Domain_2 = (IDomain)dateRangeDomain; ITable table = DatasetUtils.CreateTable(_testWs, "CanCreateDateTimeRangeDomainConstraintNotNull", FieldUtils.CreateOIDField(), dateField); List <ConstraintNode> constraints = GdbConstraintUtils.GetGdbConstraints( table, allowNullForRangeDomains: false); Assert.NotNull(constraints); foreach (ConstraintNode constraint in constraints) { Console.WriteLine(constraint); } Assert.AreEqual(2, constraints.Count); Assert.AreEqual( "DateField >= #12/31/2011 00:00:00# AND DateField <= #01/31/2012 23:55:59#", constraints[0].Condition); Assert.AreEqual("OBJECTID >= 0", constraints[1].Condition); }