public void WhenExplicitExcludedThenNotIncludeInHierarchy()
        {
            var orm = new ObjectRelationalMapper();
            orm.TablePerClass<IMyEntity>();
            orm.Exclude<ToExcludeImplEntity>();

            orm.IsRootEntity(typeof(IMyEntity)).Should().Be.True();
            orm.IsRootEntity(typeof(ToExcludeImplEntity)).Should().Be.False();

            orm.IsEntity(typeof(IMyEntity)).Should().Be.True();
            orm.IsEntity(typeof(ValidImplEntity)).Should().Be.True();
            orm.IsEntity(typeof(ToExcludeImplEntity)).Should().Be.False();
        }
        public void WhenExplicitExcludedThenNotIncludeInHierarchy()
        {
            var orm = new ObjectRelationalMapper();

            orm.TablePerClass <IMyEntity>();
            orm.Exclude <ToExcludeImplEntity>();

            orm.IsRootEntity(typeof(IMyEntity)).Should().Be.True();
            orm.IsRootEntity(typeof(ToExcludeImplEntity)).Should().Be.False();

            orm.IsEntity(typeof(IMyEntity)).Should().Be.True();
            orm.IsEntity(typeof(ValidImplEntity)).Should().Be.True();
            orm.IsEntity(typeof(ToExcludeImplEntity)).Should().Be.False();
        }
		public void WhenExplicitExcludedUsingGenericTypeDefinitionThenNotIncludeInHierarchy()
		{
			var orm = new ObjectRelationalMapper();
			orm.TablePerClass<Movement>();
			orm.Exclude(typeof(Movement<>));

			orm.IsRootEntity(typeof(Movement)).Should().Be.True();
			orm.IsRootEntity(typeof(Movement<>)).Should().Be.False();

			orm.IsEntity(typeof(Movement)).Should().Be.True();
			orm.IsEntity(typeof(Income)).Should().Be.True();
			orm.IsEntity(typeof(Outcome)).Should().Be.True();
			orm.IsEntity(typeof(Movement<string>)).Should().Be.False();
			orm.IsEntity(typeof(Movement<int>)).Should().Be.False();
		}
Пример #4
0
 private static HbmMapping GetMapping()
 {
     var orm = new ObjectRelationalMapper();
     var mapper = new Mapper(orm,
     new CoolPatternsAppliersHolder(orm));
     orm.TablePerClassHierarchy<Product>();
     orm.TablePerClass<ActorRole>();
     orm.Patterns.PoidStrategies.Add(
     new GuidOptimizedPoidPattern());
     orm.VersionProperty<Entity>(x => x.Version);
     orm.NaturalId<Product>(p => p.Name);
     orm.Cascade<Movie, ActorRole>(
     Cascade.All | Cascade.DeleteOrphans);
     mapper.AddPropertyPattern(mi =>
     mi.GetPropertyOrFieldType() == typeof(Decimal) &&
     mi.Name.Contains("Price"),
     pm => pm.Type(NHibernateUtil.Currency));
     mapper.AddPropertyPattern(mi =>
     orm.IsRootEntity(mi.DeclaringType) &&
     !"Description".Equals(mi.Name),
     pm => pm.NotNullable(true));
     mapper.Subclass<Movie>(cm =>
     cm.List(movie => movie.Actors,
     colm => colm.Index(
     lim => lim.Column("ActorIndex")), m => { }));
     var domainClasses = typeof(Entity).Assembly.GetTypes()
     .Where(t => typeof(Entity).IsAssignableFrom(t));
     return mapper.CompileMappingFor(domainClasses);
 }
        public void WhenExplicitExcludedThenNotRootEntity()
        {
            // To prevent inconsistence
            var orm = new ObjectRelationalMapper();
            orm.TablePerClass<ToExcludeImplEntity>();
            orm.Exclude<ToExcludeImplEntity>();

            orm.IsRootEntity(typeof(ToExcludeImplEntity)).Should().Be.False();
        }
        public void WhenExplicitExcludedThenNotRootEntity()
        {
            // To prevent inconsistence
            var orm = new ObjectRelationalMapper();

            orm.TablePerClass <ToExcludeImplEntity>();
            orm.Exclude <ToExcludeImplEntity>();

            orm.IsRootEntity(typeof(ToExcludeImplEntity)).Should().Be.False();
        }
 public void IsNotRecognizedAsRootEntity()
 {
     (typeof(TestSubEntity)).Satisfy(te => !mapper.IsRootEntity(te));
     (typeof(TestSubSubEntity)).Satisfy(te => !mapper.IsRootEntity(te));
 }
Пример #8
0
 public void IsRecognizedAsRootEntity()
 {
     (typeof(TestEntity)).Satisfy(te => mapper.IsRootEntity(te));
 }