public void WhenReadonlyNotDeclaredThenIsNotPersistentProperty()
		{
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			inspector.IsPersistentProperty(typeof(MyEntity).GetProperty("ReadOnly")).Should().Be.False();
		}
		public void WhenReadonlyNotDeclaredThenIsNotPersistentProperty()
		{
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			Assert.That(inspector.IsPersistentProperty(typeof(MyEntity).GetProperty("ReadOnly")), Is.False);
		}
		public void ByDefaultInheritedFromObject()
		{
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			Assert.That(inspector.IsRootEntity(typeof(Person)), Is.True);
			Assert.That(inspector.IsRootEntity(typeof(Product)), Is.False);
		}
		public void IncludesReadOnlyWithField()
		{
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;
			
			PropertyInfo pi = typeof(MyEntity).GetProperty("NoReadOnlyWithField");
			inspector.IsPersistentProperty(pi).Should().Be.True();
		}
		public void MatchWithCollectionPropertyAndArrayField()
		{
			var mi = typeof(Entity).GetProperty("Emails");
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			Assert.That(inspector.IsArray(mi), Is.True);
		}
Esempio n. 6
0
		public void WhenRelationWithTwoEntityThenIsManyToOne()
		{
			var autoinspector = new SimpleModelInspector();
			autoinspector.IsEntity((t, declared) => typeof(AEntity).Equals(t) || typeof(BEntity).Equals(t));

			var inspector = (IModelInspector)autoinspector;
			Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("B")), Is.True);
		}
Esempio n. 7
0
		public void WhenSimplePropertyThenIsNotManyToOne()
		{
			var autoinspector = new SimpleModelInspector();
			autoinspector.IsEntity((t, declared) => typeof(AEntity).Equals(t) || typeof(BEntity).Equals(t));

			var inspector = (IModelInspector)autoinspector;
			Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("Name")), Is.False);
		}
		public void NotMatchWithByteArrayProperty()
		{
			var mi = typeof(Entity).GetProperty("Bytes");
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			inspector.IsBag(mi).Should().Be.False();
		}
		public void MatchWithSetProperty()
		{
			var mi = typeof(EntityWithSets).GetProperty("NickNames");
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			inspector.IsSet(mi).Should().Be.True();
		}
		public void NotMatchWithByteArrayProperty()
		{
			var mi = typeof(Entity).GetProperty("Bytes");
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			Assert.That(inspector.IsBag(mi), Is.False);
		}
Esempio n. 11
0
		public void WhenNotExplicitlyDeclaredThenNoMatchPropertiesOutOfDefaultDelegate()
		{
			var autoinspector = new SimpleModelInspector();

			var inspector = (IModelInspector)autoinspector;
			inspector.IsPersistentId(typeof(TestEntity).GetProperty("testEntityId")).Should().Be.False();
			inspector.IsPersistentId(typeof(TestEntity).GetProperty("Something")).Should().Be.False();
		}
		public void MatchWithArrayProperty()
		{
			var mi = typeof(Entity).GetProperty("NickNames");
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			Assert.That(inspector.IsArray(mi), Is.True);
		}
		public void NotMatchWithCollectionProperty()
		{
			var mi = typeof(Entity).GetProperty("Others");
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			Assert.That(inspector.IsArray(mi), Is.False);
		}
		public void NotMatchWithCollectionField()
		{
			var mi = typeof(EntityWithSets).GetField("others", BindingFlags.NonPublic | BindingFlags.Instance);
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			inspector.IsSet(mi).Should().Be.False();
		}
		public void NotMatchWithCollectionProperty()
		{
			var mi = typeof(EntityWithSets).GetProperty("Others");
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			inspector.IsSet(mi).Should().Be.False();
		}
		public void MatchWithSetField()
		{
			var mi = typeof(EntityWithSets).GetField("emails", BindingFlags.NonPublic | BindingFlags.Instance);
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			inspector.IsSet(mi).Should().Be.True();
		}
Esempio n. 17
0
		public void ByDefaultInheritedFromObject()
		{
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			inspector.IsRootEntity(typeof(Person)).Should().Be.True();
			inspector.IsRootEntity(typeof(Product)).Should().Be.False();
		}
		public void MatchWithObjectPropertyAndEnumerableField()
		{
			var mi = typeof(Entity).GetProperty("Emails");
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			inspector.IsBag(mi).Should().Be.True();
		}
		public void NotMatchWithCollectionField()
		{
			var mi = typeof(Entity).GetField("others", BindingFlags.NonPublic | BindingFlags.Instance);
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			Assert.That(inspector.IsArray(mi), Is.False);
		}
		public void MatchWithArrayField()
		{
			var mi = typeof(Entity).GetField("emails", BindingFlags.NonPublic | BindingFlags.Instance);
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			Assert.That(inspector.IsArray(mi), Is.True);
		}
		public void MatchWithCollectionPropertyAndSetField()
		{
			var mi = typeof(EntityWithSets).GetProperty("Emails");
			var autoinspector = new SimpleModelInspector();
			var inspector = (IModelInspector)autoinspector;

			inspector.IsSet(mi).Should().Be.True();
		}
Esempio n. 22
0
		public void WhenExplicitDeclaredThenMatch()
		{
			var autoinspector = new SimpleModelInspector();
			var mapper = new ModelMapper(autoinspector);
			mapper.Class<MyClass>(map => map.Id(x => x.EntityIdentificator));

			var inspector = (IModelInspector)autoinspector;
			inspector.IsPersistentId(typeof(MyClass).GetProperty("EntityIdentificator")).Should().Be.True();
		}
Esempio n. 23
0
		public void WhenRelatedDeclaredAsOneToOneThenIsNotManyToOne()
		{
			var autoinspector = new SimpleModelInspector();
			var mapper = new ModelMapper(autoinspector);
			mapper.Class<AEntity>(map => map.OneToOne(a => a.B, x => { }));
			mapper.Class<BEntity>(x=> { });
			var inspector = (IModelInspector)autoinspector;
			Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("B")), Is.False);
		}
Esempio n. 24
0
		private IModelInspector GetConfiguredInspector()
		{
			var autoinspector = new SimpleModelInspector();
			var mapper = new ModelMapper(autoinspector);
			mapper.Class<MyClass>(x => { });
			mapper.Class<Related>(x => { });
			mapper.Class<Bidirectional>(x => { });
			return autoinspector;
		}
		public void WhenReadonlyDeclaredThenIsPersistentProperty()
		{
			var autoinspector = new SimpleModelInspector();
			var mapper = new ModelMapper(autoinspector);
			mapper.Class<MyEntity>(map => map.Property(x => x.ReadOnly));

			var inspector = (IModelInspector)autoinspector;
			inspector.IsPersistentProperty(typeof(MyEntity).GetProperty("ReadOnly")).Should().Be.True();
		}
Esempio n. 26
0
		public void WhenAClassIsExplicitlyDeclaredAsComponentThenIsComponent()
		{
			var autoinspector = new SimpleModelInspector();
			var mapper = new ModelMapper(autoinspector);
			mapper.Component<AEntity>(map => { });

			var inspector = (IModelInspector)autoinspector;
			inspector.IsComponent(typeof(AEntity)).Should().Be.True();
		}
Esempio n. 27
0
		public void WhenRelatedMatchComponentThenIsNotManyToOne()
		{
			var autoinspector = new SimpleModelInspector();
			autoinspector.IsEntity((t, declared) => typeof(AEntity).Equals(t));
			autoinspector.IsComponent((t, declared) => typeof(BEntity).Equals(t));

			var inspector = (IModelInspector)autoinspector;
			Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("B")), Is.False);
		}
Esempio n. 28
0
		public void WhenAClassIsExplicitlyDeclaredAsEntityThenIsEntity()
		{
			var autoinspector = new SimpleModelInspector();
			var mapper = new ModelMapper(autoinspector);
			mapper.Class<AComponent>(map => { });

			var inspector = (IModelInspector)autoinspector;
			Assert.That(inspector.IsEntity(typeof(AComponent)), Is.True);
		}
		public void WhenNotExplicitlyDeclaredThenIsTablePerClass()
		{
			var autoinspector = new SimpleModelInspector();
			var mapper = new ModelMapper(autoinspector);
			mapper.Class<MyClass>(x => { });
			var inspector = (IModelInspector)autoinspector;

			inspector.IsTablePerClass(typeof(MyClass)).Should().Be.True();
			inspector.IsTablePerClass(typeof(Inherited)).Should().Be.True();
		}
		public void WhenExplicitDeclaredThenMatchWithCollectionProperty()
		{
			var mi = typeof(EntityWithSets).GetProperty("Others");
			var autoinspector = new SimpleModelInspector();
			var mapper = new ModelMapper(autoinspector);
			mapper.Class<EntityWithSets>(map => map.Set(x => x.Others, x => { }, y=> {}));

			var inspector = (IModelInspector)autoinspector;
			inspector.IsSet(mi).Should().Be.True();
		}