Esempio n. 1
0
		public void WhenPropertyUsedAsPoidThenRegister()
		{
			var inspector = new ExplicitlyDeclaredModel();
			var mapper = new ModelMapper(inspector);
			mapper.Class<MyClass>(map => map.Id(x => x.Id, idmap => { }));

			Assert.That(inspector.IsPersistentId(For<MyClass>.Property(x => x.Id)), Is.True);
		}
		public void WhenPropertyUsedAsComposedIdThenRegister()
		{
			var inspector = new ExplicitlyDeclaredModel();
			var mapper = new ModelMapper(inspector);
			mapper.Class<MyClass>(map =>
															map.ComposedId(cm=>
															               {
																							 cm.Property(x => x.Code);
																							 cm.ManyToOne(x => x.Relation);
															               })
			                      );

			inspector.IsMemberOfComposedId(For<MyClass>.Property(x => x.Code)).Should().Be.True();
			inspector.IsMemberOfComposedId(For<MyClass>.Property(x => x.Relation)).Should().Be.True();
			inspector.IsPersistentProperty(For<MyClass>.Property(x => x.Code)).Should().Be.True();
			inspector.IsPersistentProperty(For<MyClass>.Property(x => x.Relation)).Should().Be.True();
			inspector.IsPersistentId(For<MyClass>.Property(x => x.Code)).Should().Be.False();
			inspector.IsPersistentId(For<MyClass>.Property(x => x.Relation)).Should().Be.False();
		}
		public void WhenPropertyUsedAsComposedIdThenRegister()
		{
			var inspector = new ExplicitlyDeclaredModel();
			var mapper = new ModelMapper(inspector);
			mapper.Class<MyClass>(map => map.ComponentAsId(x => x.Id));

			inspector.IsPersistentId(For<MyClass>.Property(x => x.Id)).Should().Be.True();
			inspector.IsPersistentProperty(For<MyClass>.Property(x => x.Id)).Should().Be.True();
			inspector.IsComponent(typeof(IMyCompo)).Should().Be.True();
		}
Esempio n. 4
0
        bool IModelInspector.IsPersistentId(MemberInfo member)
        {
            bool declaredResult = DeclaredPolymorphicMatch(member, m => declaredModel.IsPersistentId(m));

            return(isPersistentId(member, declaredResult));
        }