private IFieldMapper <T> GetFieldMapper <T>(string propName)
            where T : class, new()
        {
            var mapper = MappingFactory.CreateEntityMappingFromAnnonations <T>();

            return(mapper.FindByProperty(propName));
        }
        public void SortByName()
        {
            var entityMapper  = MappingFactory.CreateEntityMappingFromAnnonations <NotNullEntity>();
            var schemaTable   = DataSourceBuilder.BuildSchemaTableFromEntityMapping(entityMapper);
            var schemaMapping = new SchemaMapping();

            schemaMapping.Load(schemaTable);
            var columns = schemaMapping.Columns.ToArray();

            SchemaMappingColumn.SortByName(columns, "FID", "FIntProp", "FLongProp");

            Assert.AreEqual("FID", columns[0].ColumnName);
        }
Esempio n. 3
0
        private void AssertPrimaryKey <T>(string fieldName, bool identity)
            where T : class
        {
            var mapper = MappingFactory.CreateEntityMappingFromAnnonations <T>();
            var pk     = mapper.GetPrimaryKey();

            Assert.IsNotNull(pk);
            Assert.AreEqual(PrimaryKeyAttribute.PROPERTY_NAME, pk.PropertyName);
            Assert.AreEqual(fieldName, pk.FieldName);
            Assert.IsTrue(pk.IsPrimaryKey);
            Assert.AreEqual(identity, pk.Identity);
            Assert.IsFalse(pk.Insert);
            Assert.IsFalse(pk.Update);
        }
Esempio n. 4
0
        private void AssertFieldMapping <T>(string propName, string fieldName,
                                            bool insert, bool update)
            where T : class
        {
            var mapper = MappingFactory.CreateEntityMappingFromAnnonations <T>();
            var prop   = typeof(T).GetProperty(propName);
            var fm     = mapper.FindByProperty(propName);

            Assert.IsNotNull(fm);
            Assert.AreEqual(prop, fm.Property);
            Assert.AreEqual(fieldName, fm.FieldName);
            Assert.AreEqual(insert, fm.Insert);
            Assert.AreEqual(update, fm.Update);
        }
        public void BuildSchemaTableFromMapping()
        {
            var entityMapping = MappingFactory.CreateEntityMappingFromAnnonations <NotNullEntity>();
            var schemaTable   = DataSourceBuilder.BuildSchemaTableFromEntityMapping(entityMapping);

            AssertSchemaTable(schemaTable, new[]
            {
                new SchemaMappingColumn("FID", typeof(int), false),
                new SchemaMappingColumn("FIntProp", typeof(int), false),
                new SchemaMappingColumn("FShortProp", typeof(short), false),
                new SchemaMappingColumn("FLongProp", typeof(long), false),
                new SchemaMappingColumn("FFloatProp", typeof(float), false),
                new SchemaMappingColumn("FDoubleProp", typeof(double), false),
                new SchemaMappingColumn("FDecimalProp", typeof(decimal), false),
                new SchemaMappingColumn("FBoolProp", typeof(bool), false),
                new SchemaMappingColumn("FStringProp", typeof(string), true),
                new SchemaMappingColumn("FDateTimeProp", typeof(DateTime), false),
                new SchemaMappingColumn("FBinaryProp", typeof(byte[]), true),
                new SchemaMappingColumn("FGuidProp", typeof(Guid), false),
                new SchemaMappingColumn("FEnumProp", typeof(int), false),
            });
        }
Esempio n. 6
0
        public void FieldMappings_ShouldIgnoreNotMapped()
        {
            var mapper = MappingFactory.CreateEntityMappingFromAnnonations <NotNullEntity>();

            Assert.IsNull(mapper.FindByProperty("NotMappedProp"));
        }
Esempio n. 7
0
        public void EntityMapping_Derived_TableInfo()
        {
            var mapper = MappingFactory.CreateEntityMappingFromAnnonations <DerivedEntity>();

            Assert.AreEqual("TDerivedEntity", mapper.TableName);
        }
Esempio n. 8
0
        public void EntityMapping_NotNull_TableInfo()
        {
            var mapper = MappingFactory.CreateEntityMappingFromAnnonations <NotNullEntity>();

            Assert.AreEqual("TNotNullEntity", mapper.TableName);
        }
Esempio n. 9
0
 public void SetUp()
 {
     _entity = new NotNullEntity();
     _mapper = MappingFactory.CreateEntityMappingFromAnnonations <NotNullEntity>();
 }