コード例 #1
0
 public void AfterSetMultiColumnsCantSetSimpleColumn()
 {
     var hbmMapping = new HbmMapping();
     var member = typeof(MyClass).GetProperty("Relation");
     var mapping = new HbmManyToOne();
     var mapper = new ManyToOneMapper(member, mapping, hbmMapping);
     mapper.Columns(cm => cm.Length(50), cm => cm.SqlType("VARCHAR(10)"));
     ActionAssert.Throws<ConfOrm.MappingException>(() => mapper.Column(cm => cm.Length(50)));
 }
 public void SettingColumnOverridesFormula()
 {
     var hbmMapping = new HbmMapping();
     var member = ForClass<MyClass>.Property(c => c.Relation);
     var mapping = new HbmManyToOne();
     var mapper = new ManyToOneMapper(member, mapping, hbmMapping);
     mapper.Formula("formula");
     mapper.Column(cm => cm.Unique(true));
     mapping.formula.Should().Be.Null();
 }
 public void SettingColumnPlainValuesOverridesFormula()
 {
     var hbmMapping = new HbmMapping();
     var member = ForClass<MyClass>.Property(c => c.Relation);
     var mapping = new HbmManyToOne();
     var mapper = new ManyToOneMapper(member, mapping, hbmMapping);
     mapper.Formula("formula");
     mapper.Column("colName");
     mapping.formula.Should().Be.Null();
     mapping.column.Should().Be("colName");
 }
 public void SettingFormulaOverridesColumnNodes()
 {
     var hbmMapping = new HbmMapping();
     var member = ForClass<MyClass>.Property(c => c.Relation);
     var mapping = new HbmManyToOne();
     var mapper = new ManyToOneMapper(member, mapping, hbmMapping);
     mapper.Column(cm => cm.SqlType("VARCHAR(80)"));
     mapper.Formula("formula");
     mapping.formula.Should().Be("formula");
     mapping.column.Should().Be(null);
     mapping.Items.Should().Be.Null();
 }
 public void WhenSetFormulaThenResetColumn()
 {
     var hbmMapping = new HbmMapping();
     var member = ForClass<MyClass>.Property(c => c.Relation);
     var mapping = new HbmManyToOne();
     var mapper = new ManyToOneMapper(member, mapping, hbmMapping);
     mapper.Column("MyColumn");
     mapper.Formula("SomeFormula");
     mapping.formula.Should().Be("SomeFormula");
     mapping.column.Should().Be.Null();
     mapping.Items.Should().Be.Null();
 }
 public void WhenSetFormulaWithNullThenDoNothing()
 {
     var hbmMapping = new HbmMapping();
     var member = ForClass<MyClass>.Property(c => c.Relation);
     var mapping = new HbmManyToOne();
     var mapper = new ManyToOneMapper(member, mapping, hbmMapping);
     mapper.Column("MyColumn");
     mapper.Formula(null);
     mapping.formula.Should().Be.Null();
     mapping.column.Should().Not.Be.Null();
 }
コード例 #7
0
        public void WhenSetDifferentColumnNameThenSetTheName()
        {
            var hbmMapping = new HbmMapping();
            var member = typeof(MyClass).GetProperty("Relation");
            var hbm = new HbmManyToOne();
            var mapper = new ManyToOneMapper(member, hbm, hbmMapping);
            mapper.Column(cm => cm.Name("RelationId"));

            hbm.Columns.Should().Have.Count.EqualTo(1);
            hbm.Columns.Single().name.Should().Be("RelationId");
        }
コード例 #8
0
 public void WhenSetDefaultColumnNameThenDoesNotSetTheName()
 {
     var hbmMapping = new HbmMapping();
     var member = typeof(MyClass).GetProperty("Relation");
     var mapping = new HbmManyToOne();
     var mapper = new ManyToOneMapper(member, mapping, hbmMapping);
     mapper.Column(cm => cm.Name("Relation"));
     mapping.column.Should().Be.Null();
     mapping.Columns.Should().Be.Empty();
 }
コード例 #9
0
 public void WhenSetColumnValuesThenAddColumnTag()
 {
     var hbmMapping = new HbmMapping();
     var member = typeof(MyClass).GetProperty("Relation");
     var mapping = new HbmManyToOne();
     var mapper = new ManyToOneMapper(member, mapping, hbmMapping);
     mapper.Column(cm =>
     {
         cm.SqlType("BIGINT");
         cm.NotNullable(true);
     });
     mapping.Items.Should().Not.Be.Null();
     mapping.Columns.Should().Have.Count.EqualTo(1);
 }
コード例 #10
0
        public void WhenSetBasicColumnValuesThroughShortCutThenMergeColumn()
        {
            var hbmMapping = new HbmMapping();
            var member = typeof(MyClass).GetProperty("Relation");
            var mapping = new HbmManyToOne();
            var mapper = new ManyToOneMapper(member, mapping, hbmMapping);
            mapper.Column("pizza");
            mapper.NotNullable(true);
            mapper.Unique(true);
            mapper.UniqueKey("AA");
            mapper.Index("II");

            mapping.Items.Should().Be.Null();
            mapping.column.Should().Be("pizza");
            mapping.notnull.Should().Be(true);
            mapping.unique.Should().Be(true);
            mapping.uniquekey.Should().Be("AA");
            mapping.index.Should().Be("II");
        }
コード例 #11
0
 public void WhenSetBasicColumnValuesThenSetPlainValues()
 {
     var hbmMapping = new HbmMapping();
     var member = typeof(MyClass).GetProperty("Relation");
     var mapping = new HbmManyToOne();
     var mapper = new ManyToOneMapper(member, mapping, hbmMapping);
     mapper.Column(cm =>
     {
         cm.UniqueKey("theUnique");
         cm.NotNullable(true);
     });
     mapping.Items.Should().Be.Null();
     mapping.uniquekey.Should().Be("theUnique");
     mapping.notnull.Should().Be(true);
     mapping.notnullSpecified.Should().Be(true);
 }