public void WhenExplicitExcludedThenNotTablePerClassHierarchy()
        {
            // To prevent inconsistence
            var orm = new ObjectRelationalMapper();
            orm.TablePerClassHierarchy<ToExcludeImplEntity>();
            orm.Exclude<ToExcludeImplEntity>();

            orm.IsTablePerClassHierarchy(typeof(ToExcludeImplEntity)).Should().Be.False();
        }
Пример #2
0
        public void ExclusionDemo()
        {
            var orm = new ObjectRelationalMapper();

            // In this case I want exclude any implementation of Movement<TDetail> and MovementDetail<TMovement>.
            // Where the type if not generic or you have to jump a specific concrete-type you can use the method Exclude<TClass> (see ConfOrmTests.ObjectRelationalMapperTests.HierarchyClassExclusionTest)
            orm.Exclude(typeof(Movement<>));
            orm.Exclude(typeof(MovementDetail<>));

            var mapper = new Mapper(orm, new CoolPatternsAppliersHolder(orm)); // <== CoolPatternsAppliersHolder is not important... only nice to have

            // The strategy to represent classes is not important
            orm.TablePerClassHierarchy<Movement>();
            orm.TablePerClassHierarchy<MovementDetail>();

            // Show the mapping to the console
            var mapping = mapper.CompileMappingFor(typeof(Movement).Assembly.GetTypes().Where(t => t.Namespace == typeof(Movement).Namespace));
            Console.Write(mapping.AsString());
        }
        public void WhenExplicitExcludedThenNotTablePerConcreteClass()
        {
            // To prevent inconsistence
            var orm = new ObjectRelationalMapper();

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

            orm.IsTablePerConcreteClass(typeof(ToExcludeImplEntity)).Should().Be.False();
        }
Пример #4
0
        public void ExclusionDemo()
        {
            var orm = new ObjectRelationalMapper();

            // In this case I want exclude any implementation of Movement<TDetail> and MovementDetail<TMovement>.
            // Where the type if not generic or you have to jump a specific concrete-type you can use the method Exclude<TClass> (see ConfOrmTests.ObjectRelationalMapperTests.HierarchyClassExclusionTest)
            orm.Exclude(typeof(Movement <>));
            orm.Exclude(typeof(MovementDetail <>));

            var mapper = new Mapper(orm, new CoolPatternsAppliersHolder(orm));             // <== CoolPatternsAppliersHolder is not important... only nice to have

            // The strategy to represent classes is not important
            orm.TablePerClassHierarchy <Movement>();
            orm.TablePerClassHierarchy <MovementDetail>();

            // Show the mapping to the console
            var mapping = mapper.CompileMappingFor(typeof(Movement).Assembly.GetTypes().Where(t => t.Namespace == typeof(Movement).Namespace));

            Console.Write(mapping.AsString());
        }
        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();
		}
Пример #8
0
        public void WhenChangeStateOfWholeDomainThenOnlyInvalidateCache()
        {
            var domainAnalyzer = new ObjectRelationalMapper();

            domainAnalyzer.AddToDomain(typeof(MyRelation));
            domainAnalyzer.AddToDomain(typeof(MyRelation1));
            domainAnalyzer.AddToDomain(typeof(MyRelationLevel1));
            domainAnalyzer.AddToDomain(typeof(MyRelation1Lvel1));
            domainAnalyzer.AddToDomain(typeof(IRelation));
            domainAnalyzer.AddToDomain(typeof(Relation1));
            domainAnalyzer.GetBaseImplementors(typeof(Relation1));

            domainAnalyzer.Exclude(typeof(Relation1));

            domainAnalyzer.GetBaseImplementors(typeof(Relation1)).Single().Should().Be(typeof(MyRelation1));
        }
Пример #9
0
        public void WhenRegisterWholeDomainThenOnlyReturnFirstNoJumpedImplementorInTheHierarchy()
        {
            var domainAnalyzer = new ObjectRelationalMapper();

            domainAnalyzer.AddToDomain(typeof(MyRelation));
            domainAnalyzer.AddToDomain(typeof(MyRelation1));
            domainAnalyzer.AddToDomain(typeof(MyRelationLevel1));
            domainAnalyzer.AddToDomain(typeof(MyRelation1Lvel1));
            domainAnalyzer.AddToDomain(typeof(IRelation));
            domainAnalyzer.AddToDomain(typeof(Relation1));

            domainAnalyzer.Exclude(typeof(Relation1));

            domainAnalyzer.GetBaseImplementors(typeof(IRelation)).Single().Should().Be(typeof(MyRelation));
            domainAnalyzer.GetBaseImplementors(typeof(Relation1)).Single().Should().Be(typeof(MyRelation1));
        }