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"); }
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); }
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(); }
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); }