コード例 #1
0
		public void CanSetConstrained()
		{
			var hbm = new HbmOneToOne();
			var mapper = new OneToOneMapper(null, hbm);
			mapper.Constrained(true);
			hbm.constrained.Should().Be.True();
		}
コード例 #2
0
		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"));
		}
コード例 #3
0
		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")));
		}
コード例 #4
0
		public void CanSetConstrained()
		{
			var hbm = new HbmOneToOne();
			var mapper = new OneToOneMapper(null, hbm);
			mapper.Constrained(true);
			Assert.That(hbm.constrained, Is.True);
		}
コード例 #5
0
		public void WhenForeignKeyIsNullForeignKeyMappingIsNull()
		{
			var hbm = new HbmOneToOne();
			var mapper = new OneToOneMapper(null, hbm);
			mapper.ForeignKey(null);

			hbm.foreignkey.Should().Be.Null();
		}
コード例 #6
0
		public void WhenForeignKeyIsNullForeignKeyMappingIsNull()
		{
			var hbm = new HbmOneToOne();
			var mapper = new OneToOneMapper(null, hbm);
			mapper.ForeignKey(null);

			Assert.That(hbm.foreignkey, Is.Null);
		}
コード例 #7
0
		public void WhenNoMemberPropertyRefAcceptAnything()
		{
			var hbm = new HbmOneToOne();
			var mapper = new OneToOneMapper(null, hbm);
			mapper.PropertyReference(typeof(Array).GetProperty("Length"));

			hbm.propertyref.Should().Be("Length");
		}
コード例 #8
0
		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"));
		}
コード例 #9
0
		public void CanSetForeignKeyName()
		{
			var hbm = new HbmOneToOne();
			var mapper = new OneToOneMapper(null, hbm);
			mapper.ForeignKey("Id");

			Assert.That(hbm.foreignkey, Is.EqualTo("Id"));
		}
コード例 #10
0
		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));
		}
コード例 #11
0
		public void WhenNullMemberPropertyRefNull()
		{
			var hbm = new HbmOneToOne();
			var mapper = new OneToOneMapper(null, hbm);
			mapper.PropertyReference(null);

			hbm.propertyref.Should().Be.Null();
		}
コード例 #12
0
		public void CanSetForeignKeyName()
		{
			var hbm = new HbmOneToOne();
			var mapper = new OneToOneMapper(null, hbm);
			mapper.ForeignKey("Id");

			hbm.foreignkey.Should().Be("Id");
		}
コード例 #13
0
		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);
		}
コード例 #14
0
		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"));
		}
コード例 #15
0
		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");
		}
コード例 #16
0
		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>();
		}
コード例 #17
0
		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");
		}
コード例 #18
0
		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);
		}
コード例 #19
0
		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);
		}
コード例 #20
0
		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"));
		}
コード例 #21
0
		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();
		}
コード例 #22
0
		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();
		}
コード例 #23
0
		public void WhenNullMemberPropertyRefNull()
		{
			var hbm = new HbmOneToOne();
			var mapper = new OneToOneMapper(null, hbm);
			mapper.PropertyReference(null);

			Assert.That(hbm.propertyref, Is.Null);
		}
コード例 #24
0
		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>());
		}