コード例 #1
0
        public void WhenSetDifferentColumnNameThenSetTheName()
        {
            var hbmMapping = new HbmMapping();
            var member = typeof(MyComponent).GetProperty("Relation");
            var hbm = new HbmKeyManyToOne();
            var mapper = new KeyManyToOneMapper(member, hbm, hbmMapping);
            mapper.Column(cm => cm.Name("RelationId"));

            hbm.Columns.Should().Have.Count.EqualTo(1);
            hbm.Columns.Single().name.Should().Be("RelationId");
        }
コード例 #2
0
 public void WhenSetColumnValuesThenAddColumnTag()
 {
     var hbmMapping = new HbmMapping();
     var member = typeof(MyComponent).GetProperty("Relation");
     var mapping = new HbmKeyManyToOne();
     var mapper = new KeyManyToOneMapper(member, mapping, hbmMapping);
     mapper.Column(cm =>
     {
         cm.UniqueKey("theUnique");
         cm.NotNullable(true);
     });
     mapping.column.Should().Not.Be.Null();
     mapping.Columns.Should().Have.Count.EqualTo(1);
 }
コード例 #3
0
 public void WhenSetDefaultColumnNameThenDoesNotSetTheName()
 {
     var hbmMapping = new HbmMapping();
     var member = typeof(MyComponent).GetProperty("Relation");
     var mapping = new HbmKeyManyToOne();
     var mapper = new KeyManyToOneMapper(member, mapping, hbmMapping);
     mapper.Column(cm => cm.Name("Relation"));
     mapping.column.Should().Be.Null();
     mapping.Columns.Should().Be.Empty();
 }
コード例 #4
0
        public void WhenSetColumnValuesMoreThanOnesThenMergeColumn()
        {
            var hbmMapping = new HbmMapping();
            var member = typeof(MyComponent).GetProperty("Relation");
            var mapping = new HbmKeyManyToOne();
            var mapper = new KeyManyToOneMapper(member, mapping, hbmMapping);
            mapper.Column(cm => cm.UniqueKey("theUnique"));
            mapper.Column(cm => cm.NotNullable(true));

            var hbmColumn = mapping.Columns.Single();
            hbmColumn.uniquekey.Should().Be("theUnique");
            hbmColumn.notnull.Should().Be(true);
            hbmColumn.notnullSpecified.Should().Be(true);
        }