public void CanSetConstrained() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.Constrained(true); hbm.constrained.Should().Be.True(); }
public void AssignCascadeStyle() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.Cascade(Mapping.ByCode.Cascade.Persist | Mapping.ByCode.Cascade.Remove); Assert.That(hbm.cascade.Split(',').Select(w => w.Trim()), Contains.Item("persist").And.Contains("delete")); }
public void AutoCleanUnsupportedCascadeStyle() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.Cascade(Mapping.ByCode.Cascade.Persist | Mapping.ByCode.Cascade.DeleteOrphans | Mapping.ByCode.Cascade.Remove); hbm.cascade.Split(',').Select(w => w.Trim()).All(w => w.Satisfy(cascade => !cascade.Contains("orphan"))); }
public void CanSetConstrained() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.Constrained(true); Assert.That(hbm.constrained, Is.True); }
public void WhenForeignKeyIsNullForeignKeyMappingIsNull() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.ForeignKey(null); hbm.foreignkey.Should().Be.Null(); }
public void WhenForeignKeyIsNullForeignKeyMappingIsNull() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.ForeignKey(null); Assert.That(hbm.foreignkey, Is.Null); }
public void WhenNoMemberPropertyRefAcceptAnything() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.PropertyReference(typeof(Array).GetProperty("Length")); hbm.propertyref.Should().Be("Length"); }
public void WhenNoMemberPropertyRefAcceptAnything() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.PropertyReference(typeof(Array).GetProperty("Length")); Assert.That(hbm.propertyref, Is.EqualTo("Length")); }
public void CanSetForeignKeyName() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.ForeignKey("Id"); Assert.That(hbm.foreignkey, Is.EqualTo("Id")); }
public void CanSetLazyness() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.Lazy(LazyRelation.NoProxy); Assert.That(hbm.Lazy, Is.Not.Null); Assert.That(hbm.Lazy, Is.EqualTo(HbmLaziness.NoProxy)); }
public void WhenNullMemberPropertyRefNull() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.PropertyReference(null); hbm.propertyref.Should().Be.Null(); }
public void CanSetForeignKeyName() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.ForeignKey("Id"); hbm.foreignkey.Should().Be("Id"); }
public void CanSetLazyness() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.Lazy(LazyRelation.NoProxy); hbm.Lazy.Should().Have.Value(); hbm.Lazy.Should().Be(HbmLaziness.NoProxy); }
public void CanSetAccessor() { var member = typeof(MyClass).GetProperty("Relation"); var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(member, hbm); mapper.Access(Accessor.ReadOnly); Assert.That(hbm.Access, Is.EqualTo("readonly")); }
public void CanSetAccessor() { var member = typeof(MyClass).GetProperty("Relation"); var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(member, hbm); mapper.Access(Accessor.ReadOnly); hbm.Access.Should().Be("readonly"); }
public void WhenMemberPropertyRefAcceptOnlyMemberOfExpectedType() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(typeof(MyClass).GetProperty("Relation"), hbm); mapper.PropertyReference(typeof(Relation).GetProperty("Whatever")); hbm.propertyref.Should().Be("Whatever"); Executing.This(() => mapper.PropertyReference(typeof(Array).GetProperty("Length"))).Should().Throw<ArgumentOutOfRangeException>(); }
public void CanSetFormula() { var member = For<MyClass>.Property(c => c.Relation); var mapping = new HbmOneToOne(); var mapper = new OneToOneMapper(member, mapping); mapper.Formula("SomeFormula"); mapping.formula1.Should().Be("SomeFormula"); }
public void WhenSetFormulaWithMultipleLinesThenSetFormulaNode() { var member = For<MyClass>.Property(c => c.Relation); var mapping = new HbmOneToOne(); var mapper = new OneToOneMapper(member, mapping); var formula = @"Line1 Line2"; mapper.Formula(formula); Assert.That(mapping.formula1, Is.Null); var hbmFormula = mapping.formula.First(); Assert.That(hbmFormula.Text.Length, Is.EqualTo(2)); Assert.That(hbmFormula.Text[0], Is.EqualTo("Line1")); Assert.That(hbmFormula.Text[1], Is.EqualTo("Line2")); Assert.That(mapping.formula1, Is.Null); }
public void WhenSetFormulaWithNullThenSetFormulaWithNull() { var member = For<MyClass>.Property(c => c.Relation); var mapping = new HbmOneToOne(); var mapper = new OneToOneMapper(member, mapping); mapper.Formula(null); Assert.That(mapping.formula, Is.Null); Assert.That(mapping.formula1, Is.Null); }
public void CanSetFormula() { var member = For<MyClass>.Property(c => c.Relation); var mapping = new HbmOneToOne(); var mapper = new OneToOneMapper(member, mapping); mapper.Formula("SomeFormula"); Assert.That(mapping.formula1, Is.EqualTo("SomeFormula")); }
public void WhenSetFormulaWithNullThenSetFormulaWithNull() { var member = For<MyClass>.Property(c => c.Relation); var mapping = new HbmOneToOne(); var mapper = new OneToOneMapper(member, mapping); mapper.Formula(null); mapping.formula.Should().Be.Null(); mapping.formula1.Should().Be.Null(); }
public void WhenSetFormulaWithMultipleLinesThenSetFormulaNode() { var member = For<MyClass>.Property(c => c.Relation); var mapping = new HbmOneToOne(); var mapper = new OneToOneMapper(member, mapping); var formula = @"Line1 Line2"; mapper.Formula(formula); mapping.formula1.Should().Be.Null(); var hbmFormula = mapping.formula.First(); hbmFormula.Text.Length.Should().Be(2); hbmFormula.Text[0].Should().Be("Line1"); hbmFormula.Text[1].Should().Be("Line2"); mapping.formula1.Should().Be.Null(); }
public void WhenNullMemberPropertyRefNull() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(null, hbm); mapper.PropertyReference(null); Assert.That(hbm.propertyref, Is.Null); }
public void WhenMemberPropertyRefAcceptOnlyMemberOfExpectedType() { var hbm = new HbmOneToOne(); var mapper = new OneToOneMapper(typeof(MyClass).GetProperty("Relation"), hbm); mapper.PropertyReference(typeof(Relation).GetProperty("Whatever")); Assert.That(hbm.propertyref, Is.EqualTo("Whatever")); Assert.That(() => mapper.PropertyReference(typeof(Array).GetProperty("Length")), Throws.TypeOf<ArgumentOutOfRangeException>()); }