public void TestCloneProperty()
        {
            DataPropertyDefinition dp = new DataPropertyDefinition("Foo", "Bar");

            dp.DataType        = DataType.DataType_String;
            dp.DefaultValue    = "Whatever";
            dp.IsAutoGenerated = false;
            dp.Length          = 45;
            dp.Nullable        = true;
            dp.ReadOnly        = false;
            PropertyValueConstraintList list = new PropertyValueConstraintList();

            list.ConstraintList.Add(new StringValue("A"));
            list.ConstraintList.Add(new StringValue("B"));
            list.ConstraintList.Add(new StringValue("C"));
            dp.ValueConstraint = list;

            DataPropertyDefinition dp2 = FdoSchemaUtil.CloneProperty(dp) as DataPropertyDefinition;

            AssertHelper.EqualProperty(dp, dp2);

            GeometricPropertyDefinition gp = new GeometricPropertyDefinition("Sna", "Fu");

            gp.GeometryTypes             = (int)(GeometryType.GeometryType_LineString | GeometryType.GeometryType_MultiLineString | GeometryType.GeometryType_Polygon);
            gp.HasElevation              = true;
            gp.HasMeasure                = false;
            gp.ReadOnly                  = false;
            gp.SpatialContextAssociation = "LL84";

            GeometricPropertyDefinition gp2 = FdoSchemaUtil.CloneProperty(gp) as GeometricPropertyDefinition;

            AssertHelper.EqualProperty(gp, gp2);
        }
Example #2
0
        /// <summary>
        /// Clones a given property definition
        /// </summary>
        /// <param name="pd"></param>
        /// <returns></returns>
        public static PropertyDefinition CloneProperty(PropertyDefinition pd)
        {
            PropertyDefinition propDef = null;
            switch (pd.PropertyType)
            {
                case PropertyType.PropertyType_DataProperty:
                    {
                        DataPropertyDefinition srcData = pd as DataPropertyDefinition;
                        DataPropertyDefinition dataDef = new DataPropertyDefinition(srcData.Name, srcData.Description);
                        dataDef.DataType = srcData.DataType;
                        dataDef.DefaultValue = srcData.DefaultValue;
                        dataDef.IsAutoGenerated = srcData.IsAutoGenerated;
                        dataDef.IsSystem = srcData.IsSystem;
                        dataDef.Length = srcData.Length;
                        dataDef.Nullable = srcData.Nullable;
                        dataDef.Precision = srcData.Precision;
                        dataDef.ReadOnly = srcData.ReadOnly;
                        //Copy constraints
                        if (srcData.ValueConstraint != null)
                        {
                            if (srcData.ValueConstraint.ConstraintType == PropertyValueConstraintType.PropertyValueConstraintType_Range)
                            {
                                PropertyValueConstraintRange range = (PropertyValueConstraintRange)srcData.ValueConstraint;
                                PropertyValueConstraintRange constraint = new PropertyValueConstraintRange(range.MinValue, range.MaxValue);
                                constraint.MaxInclusive = range.MaxInclusive;
                                constraint.MinInclusive = range.MinInclusive;
                                dataDef.ValueConstraint = constraint;
                            }
                            else if (srcData.ValueConstraint.ConstraintType == PropertyValueConstraintType.PropertyValueConstraintType_List)
                            {
                                PropertyValueConstraintList list = (PropertyValueConstraintList)srcData.ValueConstraint;
                                PropertyValueConstraintList constraint = new PropertyValueConstraintList();
                                foreach (DataValue dval in list.ConstraintList)
                                {
                                    constraint.ConstraintList.Add(dval);
                                }
                                dataDef.ValueConstraint = constraint;
                            }
                        }
                        CopyPropertyAttributes(srcData, dataDef);
                        propDef = dataDef;
                    }
                    break;
                case PropertyType.PropertyType_GeometricProperty:
                    {
                        GeometricPropertyDefinition srcData = pd as GeometricPropertyDefinition;
                        GeometricPropertyDefinition geomDef = new GeometricPropertyDefinition(srcData.Name, srcData.Description);
                        geomDef.GeometryTypes = srcData.GeometryTypes;
                        geomDef.HasElevation = srcData.HasElevation;
                        geomDef.HasMeasure = srcData.HasMeasure;
                        geomDef.IsSystem = srcData.IsSystem;
                        geomDef.ReadOnly = srcData.ReadOnly;
                        geomDef.SpatialContextAssociation = srcData.SpatialContextAssociation;
                        CopyPropertyAttributes(srcData, geomDef);
                        propDef = geomDef;
                    }
                    break;
                case PropertyType.PropertyType_RasterProperty:
                    {
                        RasterPropertyDefinition srcData = pd as RasterPropertyDefinition;
                        RasterPropertyDefinition rastDef = new RasterPropertyDefinition(srcData.Name, srcData.Description);
                        if (srcData.DefaultDataModel != null)
                        {
                            rastDef.DefaultDataModel = new OSGeo.FDO.Raster.RasterDataModel();
                            rastDef.DefaultDataModel.BitsPerPixel = srcData.DefaultDataModel.BitsPerPixel;
                            rastDef.DefaultDataModel.DataModelType = srcData.DefaultDataModel.DataModelType;
                            rastDef.DefaultDataModel.DataType = srcData.DefaultDataModel.DataType;
                            rastDef.DefaultDataModel.Organization = srcData.DefaultDataModel.Organization;
                            rastDef.DefaultDataModel.TileSizeX = srcData.DefaultDataModel.TileSizeX;
                            rastDef.DefaultDataModel.TileSizeY = srcData.DefaultDataModel.TileSizeY;
                        }
                        rastDef.DefaultImageXSize = srcData.DefaultImageXSize;
                        rastDef.DefaultImageYSize = srcData.DefaultImageYSize;
                        rastDef.IsSystem = srcData.IsSystem;
                        rastDef.Nullable = srcData.Nullable;
                        rastDef.ReadOnly = srcData.ReadOnly;
                        rastDef.SpatialContextAssociation = srcData.SpatialContextAssociation;
                        CopyPropertyAttributes(srcData, rastDef);
                        propDef = rastDef;
                    }
                    break;
                case PropertyType.PropertyType_AssociationProperty:
                    throw new UnsupportedException(Res.GetString("ERR_UNSUPPORTED_CLONE_ASSOCIATION"));
                case PropertyType.PropertyType_ObjectProperty:
                    throw new UnsupportedException(Res.GetString("ERR_UNSUPPORTED_CLONE_OBJECT"));

            }
            return propDef;
        }
        public void TestAlterSchemaPassValueConstraints()
        {
            MockRepository      mocks = new MockRepository();
            IConnection         conn  = mocks.DynamicMock <IConnection>();
            ISchemaCapabilities caps  = mocks.DynamicMock <ISchemaCapabilities>();

            using (mocks.Record())
            {
                SetupResult.For(conn.ConnectionState).Return(ConnectionState.ConnectionState_Open);
                SetupResult.For(conn.SchemaCapabilities).Return(caps);
                SetupResult.For(caps.ClassTypes).Return((ClassType[])Enum.GetValues(typeof(ClassType)));
                SetupResult.For(caps.DataTypes).Return((DataType[])Enum.GetValues(typeof(DataType)));
                SetupResult.For(caps.MaximumDecimalPrecision).Return(20);
                SetupResult.For(caps.MaximumDecimalScale).Return(20);
                SetupResult.For(caps.ReservedCharactersForName).Return(string.Empty);
                SetupResult.For(caps.SupportedAutoGeneratedTypes).Return(new DataType[] { DataType.DataType_Int64 });
                SetupResult.For(caps.SupportedIdentityPropertyTypes).Return(new DataType[] { DataType.DataType_Int32, DataType.DataType_Int64 });
                SetupResult.For(caps.SupportsAssociationProperties).Return(false);
                SetupResult.For(caps.SupportsAutoIdGeneration).Return(true);
                SetupResult.For(caps.SupportsCompositeId).Return(false);
                SetupResult.For(caps.SupportsCompositeUniqueValueConstraints).Return(false);
                SetupResult.For(caps.SupportsDataStoreScopeUniqueIdGeneration).Return(false);
                SetupResult.For(caps.SupportsDefaultValue).Return(true);
                //--
                SetupResult.For(caps.SupportsExclusiveValueRangeConstraints).Return(false);
                SetupResult.For(caps.SupportsInclusiveValueRangeConstraints).Return(false);
                //--
                SetupResult.For(caps.SupportsMultipleSchemas).Return(false);
                SetupResult.For(caps.SupportsNetworkModel).Return(false);
                SetupResult.For(caps.SupportsNullValueConstraints).Return(true);
                SetupResult.For(caps.SupportsObjectProperties).Return(false);
                SetupResult.For(caps.SupportsSchemaModification).Return(true);
                SetupResult.For(caps.SupportsSchemaOverrides).Return(false);
                SetupResult.For(caps.SupportsUniqueValueConstraints).Return(false);
                //--
                SetupResult.For(caps.SupportsValueConstraintsList).Return(false);
                //--
                SetupResult.For(caps.SupportsInheritance).Return(false);
            }
            FdoFeatureService service = mocks.StrictMock <FdoFeatureService>(conn);

            mocks.ReplayAll();

            FeatureSchema schema = new FeatureSchema("Default", "");

            ClassDefinition cls = new Class("Test", "");

            //ID
            DataPropertyDefinition id = new DataPropertyDefinition("ID", "");

            id.DataType        = DataType.DataType_Int64;
            id.IsAutoGenerated = true; //Should be converted to int64
            id.ReadOnly        = true;
            id.Nullable        = false;

            cls.Properties.Add(id);
            cls.IdentityProperties.Add(id);

            //Age
            DataPropertyDefinition       age   = new DataPropertyDefinition("Age", "");
            PropertyValueConstraintRange range = new PropertyValueConstraintRange();

            range.MinValue      = new Int32Value(0);
            range.MinInclusive  = true;
            range.MaxValue      = new Int32Value(100);
            range.MaxInclusive  = true;
            age.ValueConstraint = range;
            age.DataType        = DataType.DataType_Int32;
            age.Nullable        = true;

            cls.Properties.Add(age);

            //Gender
            DataPropertyDefinition      gender = new DataPropertyDefinition("Gender", "");
            PropertyValueConstraintList list   = new PropertyValueConstraintList();

            list.ConstraintList.Add(new StringValue("M"));
            list.ConstraintList.Add(new StringValue("F"));
            gender.ValueConstraint = list;
            age.DataType           = DataType.DataType_String;
            age.Nullable           = false;
            age.Length             = 1;

            cls.Properties.Add(gender);

            schema.Classes.Add(cls);

            IncompatibleSchema incSchema = null;
            bool canApply = service.CanApplySchema(schema, out incSchema);

            Assert.IsFalse(canApply);
            Assert.IsNotNull(incSchema);

            FeatureSchema newSchema = service.AlterSchema(schema, incSchema);

            ClassDefinition newClass = newSchema.Classes[0];

            DataPropertyDefinition age2 = newClass.Properties[newClass.Properties.IndexOf("Age")] as DataPropertyDefinition;

            //Should have constraint removed
            Assert.IsNull(age2.ValueConstraint);

            DataPropertyDefinition gender2 = newClass.Properties[newClass.Properties.IndexOf("Gender")] as DataPropertyDefinition;

            //Should have constraint removed
            Assert.IsNull(gender2.ValueConstraint);
        }
Example #4
0
        /// <summary>
        /// Clones a given property definition
        /// </summary>
        /// <param name="pd"></param>
        /// <returns></returns>
        public static PropertyDefinition CloneProperty(PropertyDefinition pd)
        {
            PropertyDefinition propDef = null;

            switch (pd.PropertyType)
            {
            case PropertyType.PropertyType_DataProperty:
            {
                DataPropertyDefinition srcData = pd as DataPropertyDefinition;
                DataPropertyDefinition dataDef = new DataPropertyDefinition(srcData.Name, srcData.Description);
                dataDef.DataType        = srcData.DataType;
                dataDef.DefaultValue    = srcData.DefaultValue;
                dataDef.IsAutoGenerated = srcData.IsAutoGenerated;
                dataDef.IsSystem        = srcData.IsSystem;
                dataDef.Length          = srcData.Length;
                dataDef.Nullable        = srcData.Nullable;
                dataDef.Precision       = srcData.Precision;
                dataDef.ReadOnly        = srcData.ReadOnly;
                //Copy constraints
                if (srcData.ValueConstraint != null)
                {
                    if (srcData.ValueConstraint.ConstraintType == PropertyValueConstraintType.PropertyValueConstraintType_Range)
                    {
                        PropertyValueConstraintRange range      = (PropertyValueConstraintRange)srcData.ValueConstraint;
                        PropertyValueConstraintRange constraint = new PropertyValueConstraintRange(range.MinValue, range.MaxValue);
                        constraint.MaxInclusive = range.MaxInclusive;
                        constraint.MinInclusive = range.MinInclusive;
                        dataDef.ValueConstraint = constraint;
                    }
                    else if (srcData.ValueConstraint.ConstraintType == PropertyValueConstraintType.PropertyValueConstraintType_List)
                    {
                        PropertyValueConstraintList list       = (PropertyValueConstraintList)srcData.ValueConstraint;
                        PropertyValueConstraintList constraint = new PropertyValueConstraintList();
                        foreach (DataValue dval in list.ConstraintList)
                        {
                            constraint.ConstraintList.Add(dval);
                        }
                        dataDef.ValueConstraint = constraint;
                    }
                }
                CopyPropertyAttributes(srcData, dataDef);
                propDef = dataDef;
            }
            break;

            case PropertyType.PropertyType_GeometricProperty:
            {
                GeometricPropertyDefinition srcData = pd as GeometricPropertyDefinition;
                GeometricPropertyDefinition geomDef = new GeometricPropertyDefinition(srcData.Name, srcData.Description);
                geomDef.GeometryTypes             = srcData.GeometryTypes;
                geomDef.HasElevation              = srcData.HasElevation;
                geomDef.HasMeasure                = srcData.HasMeasure;
                geomDef.IsSystem                  = srcData.IsSystem;
                geomDef.ReadOnly                  = srcData.ReadOnly;
                geomDef.SpatialContextAssociation = srcData.SpatialContextAssociation;
                CopyPropertyAttributes(srcData, geomDef);
                propDef = geomDef;
            }
            break;

            case PropertyType.PropertyType_RasterProperty:
            {
                RasterPropertyDefinition srcData = pd as RasterPropertyDefinition;
                RasterPropertyDefinition rastDef = new RasterPropertyDefinition(srcData.Name, srcData.Description);
                if (srcData.DefaultDataModel != null)
                {
                    rastDef.DefaultDataModel = new OSGeo.FDO.Raster.RasterDataModel();
                    rastDef.DefaultDataModel.BitsPerPixel  = srcData.DefaultDataModel.BitsPerPixel;
                    rastDef.DefaultDataModel.DataModelType = srcData.DefaultDataModel.DataModelType;
                    rastDef.DefaultDataModel.DataType      = srcData.DefaultDataModel.DataType;
                    rastDef.DefaultDataModel.Organization  = srcData.DefaultDataModel.Organization;
                    rastDef.DefaultDataModel.TileSizeX     = srcData.DefaultDataModel.TileSizeX;
                    rastDef.DefaultDataModel.TileSizeY     = srcData.DefaultDataModel.TileSizeY;
                }
                rastDef.DefaultImageXSize         = srcData.DefaultImageXSize;
                rastDef.DefaultImageYSize         = srcData.DefaultImageYSize;
                rastDef.IsSystem                  = srcData.IsSystem;
                rastDef.Nullable                  = srcData.Nullable;
                rastDef.ReadOnly                  = srcData.ReadOnly;
                rastDef.SpatialContextAssociation = srcData.SpatialContextAssociation;
                CopyPropertyAttributes(srcData, rastDef);
                propDef = rastDef;
            }
            break;

            case PropertyType.PropertyType_AssociationProperty:
                throw new UnsupportedException(Res.GetString("ERR_UNSUPPORTED_CLONE_ASSOCIATION"));

            case PropertyType.PropertyType_ObjectProperty:
                throw new UnsupportedException(Res.GetString("ERR_UNSUPPORTED_CLONE_OBJECT"));
            }
            return(propDef);
        }
Example #5
0
        /// <summary>
        /// Adds the data property.
        /// </summary>
        /// <param name="dataDef">The data def.</param>
        /// <param name="value">The update value</param>
        /// <param name="szClassHierarchy">The class name hierarchy.</param>
        public void AddDataProperty(DataPropertyDefinition dataDef, object value, String szClassHierarchy)
        {
            if (dataDef.IsAutoGenerated || dataDef.ReadOnly)
            {
                return;
            }

            DataGridViewRow         row      = new DataGridViewRow();
            DataGridViewTextBoxCell nameCell = new DataGridViewTextBoxCell();

            if (!String.IsNullOrEmpty(szClassHierarchy))
            {
                nameCell.Value = szClassHierarchy + ".";
            }
            nameCell.Value += dataDef.Name;

            nameCell.ToolTipText = "Type: " + dataDef.DataType;
            nameCell.Tag         = dataDef;

            DataGridViewCell valueCell = null;

            if (dataDef.ValueConstraint != null && dataDef.ValueConstraint.ConstraintType == PropertyValueConstraintType.PropertyValueConstraintType_List)
            {
                PropertyValueConstraintList list = (dataDef.ValueConstraint as PropertyValueConstraintList);
                DataGridViewComboBoxCell    cc   = new DataGridViewComboBoxCell();
                List <string> values             = new List <string>();
                foreach (DataValue dv in list.ConstraintList)
                {
                    values.Add(dv.ToString());
                }
                cc.DataSource = values;
                valueCell     = cc;
            }
            else
            {
                switch (dataDef.DataType)
                {
                case DataType.DataType_BLOB:
                {
                    DataGridViewTextBoxCell tc = new DataGridViewTextBoxCell();
                    tc.MaxInputLength = dataDef.Length;
                    valueCell         = tc;
                }
                break;

                case DataType.DataType_Boolean:
                    valueCell = new DataGridViewTextBoxCell();
                    break;

                case DataType.DataType_Byte:
                    valueCell = new DataGridViewTextBoxCell();
                    break;

                case DataType.DataType_CLOB:
                {
                    DataGridViewTextBoxCell tc = new DataGridViewTextBoxCell();
                    tc.MaxInputLength = dataDef.Length;
                    valueCell         = tc;
                }
                break;

                case DataType.DataType_DateTime:
                    valueCell = new DataGridViewTextBoxCell();
                    break;

                case DataType.DataType_Decimal:
                    valueCell = new DataGridViewTextBoxCell();
                    break;

                case DataType.DataType_Double:
                    valueCell = new DataGridViewTextBoxCell();
                    break;

                case DataType.DataType_Int16:
                    valueCell = new DataGridViewTextBoxCell();
                    break;

                case DataType.DataType_Int32:
                    valueCell = new DataGridViewTextBoxCell();
                    break;

                case DataType.DataType_Int64:
                    valueCell = new DataGridViewTextBoxCell();
                    break;

                case DataType.DataType_Single:
                    valueCell = new DataGridViewTextBoxCell();
                    break;

                case DataType.DataType_String:
                {
                    DataGridViewTextBoxCell tc = new DataGridViewTextBoxCell();
                    tc.MaxInputLength = dataDef.Length;
                    valueCell         = tc;
                }
                break;
                }
            }
            valueCell.Style.BackColor = dataDef.Nullable ? Color.YellowGreen : Color.White;
            valueCell.Value           = value == null ? dataDef.DefaultValue : value;
            valueCell.ToolTipText     = dataDef.Description;

            row.Cells.Add(nameCell);
            row.Cells.Add(valueCell);

            nameCell.ReadOnly = true;

            grdProperties.Rows.Add(row);
        }
Example #6
0
        public static void EqualProperty(PropertyDefinition propDef, PropertyDefinition pd)
        {
            Assert.AreEqual(propDef.Name, pd.Name);
            Assert.AreEqual(propDef.PropertyType, pd.PropertyType);

            switch (propDef.PropertyType)
            {
            case PropertyType.PropertyType_DataProperty:
            {
                DataPropertyDefinition d1 = propDef as DataPropertyDefinition;
                DataPropertyDefinition d2 = pd as DataPropertyDefinition;

                Assert.AreEqual(d1.DefaultValue, d2.DefaultValue);
                Assert.AreEqual(d1.Description, d2.Description);
                Assert.AreEqual(d1.IsAutoGenerated, d2.IsAutoGenerated);
                Assert.AreEqual(d1.IsSystem, d2.IsSystem);
                Assert.AreEqual(d1.Length, d2.Length);
                Assert.AreEqual(d1.Nullable, d2.Nullable);
                Assert.AreEqual(d1.Precision, d2.Precision);
                Assert.AreEqual(d1.ReadOnly, d2.ReadOnly);
                Assert.AreEqual(d1.Scale, d2.Scale);

                if (d1.ValueConstraint != null)
                {
                    Assert.IsNotNull(d2.ValueConstraint);
                    Assert.AreEqual(d1.ValueConstraint.ConstraintType, d1.ValueConstraint.ConstraintType);
                    switch (d1.ValueConstraint.ConstraintType)
                    {
                    case PropertyValueConstraintType.PropertyValueConstraintType_List:
                    {
                        PropertyValueConstraintList list1 = (PropertyValueConstraintList)d1.ValueConstraint;
                        PropertyValueConstraintList list2 = (PropertyValueConstraintList)d2.ValueConstraint;

                        Assert.AreEqual(list1.ConstraintList.Count, list2.ConstraintList.Count);

                        foreach (DataValue val in list1.ConstraintList)
                        {
                            Assert.IsTrue(list2.ConstraintList.Contains(val));
                        }
                    }
                    break;

                    case PropertyValueConstraintType.PropertyValueConstraintType_Range:
                    {
                        PropertyValueConstraintRange range1 = (PropertyValueConstraintRange)d1.ValueConstraint;
                        PropertyValueConstraintRange range2 = (PropertyValueConstraintRange)d2.ValueConstraint;

                        Assert.AreEqual(range1.MaxInclusive, range2.MaxInclusive);
                        Assert.AreEqual(range1.MaxValue.ToString(), range2.MaxValue.ToString());
                        Assert.AreEqual(range1.MinInclusive, range2.MinInclusive);
                        Assert.AreEqual(range1.MinValue.ToString(), range2.MinValue.ToString());
                    }
                    break;
                    }
                }
                else
                {
                    Assert.IsNull(d2.ValueConstraint);
                }
            }
            break;

            case PropertyType.PropertyType_GeometricProperty:
            {
                GeometricPropertyDefinition g1 = (GeometricPropertyDefinition)propDef;
                GeometricPropertyDefinition g2 = (GeometricPropertyDefinition)pd;

                Assert.AreEqual(g1.GeometryTypes, g2.GeometryTypes);
                Assert.AreEqual(g1.HasElevation, g2.HasElevation);
                Assert.AreEqual(g1.HasMeasure, g2.HasMeasure);
                Assert.AreEqual(g1.SpatialContextAssociation, g2.SpatialContextAssociation);
            }
            break;
            }
        }
        public void TestCloneProperty()
        {
            DataPropertyDefinition dp = new DataPropertyDefinition("Foo", "Bar");
            dp.DataType = DataType.DataType_String;
            dp.DefaultValue = "Whatever";
            dp.IsAutoGenerated = false;
            dp.Length = 45;
            dp.Nullable = true;
            dp.ReadOnly = false;
            PropertyValueConstraintList list = new PropertyValueConstraintList();
            list.ConstraintList.Add(new StringValue("A"));
            list.ConstraintList.Add(new StringValue("B"));
            list.ConstraintList.Add(new StringValue("C"));
            dp.ValueConstraint = list;

            DataPropertyDefinition dp2 = FdoSchemaUtil.CloneProperty(dp) as DataPropertyDefinition;
            AssertHelper.EqualProperty(dp, dp2);

            GeometricPropertyDefinition gp = new GeometricPropertyDefinition("Sna", "Fu");
            gp.GeometryTypes = (int)(GeometryType.GeometryType_LineString | GeometryType.GeometryType_MultiLineString | GeometryType.GeometryType_Polygon);
            gp.HasElevation = true;
            gp.HasMeasure = false;
            gp.ReadOnly = false;
            gp.SpatialContextAssociation = "LL84";

            GeometricPropertyDefinition gp2 = FdoSchemaUtil.CloneProperty(gp) as GeometricPropertyDefinition;
            AssertHelper.EqualProperty(gp, gp2);
        }
        public void TestAlterSchemaPassValueConstraints()
        {
            MockRepository mocks = new MockRepository();
            IConnection conn = mocks.DynamicMock<IConnection>();
            ISchemaCapabilities caps = mocks.DynamicMock<ISchemaCapabilities>();

            using (mocks.Record())
            {
                SetupResult.For(conn.ConnectionState).Return(ConnectionState.ConnectionState_Open);
                SetupResult.For(conn.SchemaCapabilities).Return(caps);
                SetupResult.For(caps.ClassTypes).Return((ClassType[])Enum.GetValues(typeof(ClassType)));
                SetupResult.For(caps.DataTypes).Return((DataType[])Enum.GetValues(typeof(DataType)));
                SetupResult.For(caps.MaximumDecimalPrecision).Return(20);
                SetupResult.For(caps.MaximumDecimalScale).Return(20);
                SetupResult.For(caps.ReservedCharactersForName).Return(string.Empty);
                SetupResult.For(caps.SupportedAutoGeneratedTypes).Return(new DataType[] { DataType.DataType_Int64 });
                SetupResult.For(caps.SupportedIdentityPropertyTypes).Return(new DataType[] { DataType.DataType_Int32, DataType.DataType_Int64 });
                SetupResult.For(caps.SupportsAssociationProperties).Return(false);
                SetupResult.For(caps.SupportsAutoIdGeneration).Return(true);
                SetupResult.For(caps.SupportsCompositeId).Return(false);
                SetupResult.For(caps.SupportsCompositeUniqueValueConstraints).Return(false);
                SetupResult.For(caps.SupportsDataStoreScopeUniqueIdGeneration).Return(false);
                SetupResult.For(caps.SupportsDefaultValue).Return(true);
                //--
                SetupResult.For(caps.SupportsExclusiveValueRangeConstraints).Return(false);
                SetupResult.For(caps.SupportsInclusiveValueRangeConstraints).Return(false);
                //--
                SetupResult.For(caps.SupportsMultipleSchemas).Return(false);
                SetupResult.For(caps.SupportsNetworkModel).Return(false);
                SetupResult.For(caps.SupportsNullValueConstraints).Return(true);
                SetupResult.For(caps.SupportsObjectProperties).Return(false);
                SetupResult.For(caps.SupportsSchemaModification).Return(true);
                SetupResult.For(caps.SupportsSchemaOverrides).Return(false);
                SetupResult.For(caps.SupportsUniqueValueConstraints).Return(false);
                //--
                SetupResult.For(caps.SupportsValueConstraintsList).Return(false);
                //--
                SetupResult.For(caps.SupportsInheritance).Return(false);
            }
            FdoFeatureService service = mocks.StrictMock<FdoFeatureService>(conn);
            mocks.ReplayAll();

            FeatureSchema schema = new FeatureSchema("Default", "");

            ClassDefinition cls = new Class("Test", "");

            //ID
            DataPropertyDefinition id = new DataPropertyDefinition("ID", "");
            id.DataType = DataType.DataType_Int64;
            id.IsAutoGenerated = true; //Should be converted to int64
            id.ReadOnly = true;
            id.Nullable = false;

            cls.Properties.Add(id);
            cls.IdentityProperties.Add(id);

            //Age
            DataPropertyDefinition age = new DataPropertyDefinition("Age", "");
            PropertyValueConstraintRange range = new PropertyValueConstraintRange();
            range.MinValue = new Int32Value(0);
            range.MinInclusive = true;
            range.MaxValue = new Int32Value(100);
            range.MaxInclusive = true;
            age.ValueConstraint = range;
            age.DataType = DataType.DataType_Int32;
            age.Nullable = true;

            cls.Properties.Add(age);

            //Gender
            DataPropertyDefinition gender = new DataPropertyDefinition("Gender", "");
            PropertyValueConstraintList list = new PropertyValueConstraintList();
            list.ConstraintList.Add(new StringValue("M"));
            list.ConstraintList.Add(new StringValue("F"));
            gender.ValueConstraint = list;
            age.DataType = DataType.DataType_String;
            age.Nullable = false;
            age.Length = 1;

            cls.Properties.Add(gender);

            schema.Classes.Add(cls);

            IncompatibleSchema incSchema = null;
            bool canApply = service.CanApplySchema(schema, out incSchema);
            Assert.IsFalse(canApply);
            Assert.IsNotNull(incSchema);

            FeatureSchema newSchema = service.AlterSchema(schema, incSchema);

            ClassDefinition newClass = newSchema.Classes[0];

            DataPropertyDefinition age2 = newClass.Properties[newClass.Properties.IndexOf("Age")] as DataPropertyDefinition;

            //Should have constraint removed
            Assert.IsNull(age2.ValueConstraint);

            DataPropertyDefinition gender2 = newClass.Properties[newClass.Properties.IndexOf("Gender")] as DataPropertyDefinition;
            //Should have constraint removed
            Assert.IsNull(gender2.ValueConstraint);
        }