示例#1
0
        public void AfterSetMultiColumnsCantSetSimpleColumn()
        {
            var hbmMapping = new HbmMapping();
            var member     = typeof(MyComponent).GetProperty("Relation");
            var mapping    = new HbmKeyManyToOne();
            var mapper     = new KeyManyToOneMapper(member, mapping, hbmMapping);

            mapper.Columns(cm => cm.Length(50), cm => cm.SqlType("VARCHAR(10)"));
            mapper.Executing(m => m.Column(cm => cm.Length(50))).Throws <MappingException>();
        }
示例#2
0
        public void WhenSetMultiColumnsValuesThenAutoassignColumnNames()
        {
            var hbmMapping = new HbmMapping();
            var member     = typeof(MyComponent).GetProperty("Relation");
            var mapping    = new HbmKeyManyToOne();
            var mapper     = new KeyManyToOneMapper(member, mapping, hbmMapping);

            mapper.Columns(cm => cm.Length(50), cm => cm.SqlType("VARCHAR(10)"));
            mapping.Columns.Should().Have.Count.EqualTo(2);
            mapping.Columns.All(cm => cm.name.Satisfy(n => !string.IsNullOrEmpty(n)));
        }
示例#3
0
        public void WhenSetMultiColumnsValuesThenAddColumns()
        {
            var hbmMapping = new HbmMapping();
            var member     = typeof(MyComponent).GetProperty("Relation");
            var mapping    = new HbmKeyManyToOne();
            var mapper     = new KeyManyToOneMapper(member, mapping, hbmMapping);

            mapper.Columns(cm =>
            {
                cm.Name("column1");
                cm.Length(50);
            }, cm =>
            {
                cm.Name("column2");
                cm.SqlType("VARCHAR(10)");
            });
            mapping.Columns.Should().Have.Count.EqualTo(2);
        }