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(); }
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"); }
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); }
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"); }
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)")); Executing.This(() => mapper.Column(cm => cm.Length(50))).Should().Throw<MappingException>(); }
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); }
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); }); Assert.That(mapping.Items, Is.Not.Null); Assert.That(mapping.Columns.Count(), Is.EqualTo(1)); }
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); }); Assert.That(mapping.Items, Is.Null); Assert.That(mapping.uniquekey, Is.EqualTo("theUnique")); Assert.That(mapping.notnull, Is.EqualTo(true)); Assert.That(mapping.notnullSpecified, Is.EqualTo(true)); }
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"); Assert.That(mapping.Items, Is.Null); Assert.That(mapping.column, Is.EqualTo("pizza")); Assert.That(mapping.notnull, Is.EqualTo(true)); Assert.That(mapping.unique, Is.EqualTo(true)); Assert.That(mapping.uniquekey, Is.EqualTo("AA")); Assert.That(mapping.index, Is.EqualTo("II")); }