Example #1
0
        public void BuildConfigurationFromAssemblies_Multiple()
        {
            var assemblies = new[] { typeof(BaseType1).Assembly, typeof(DisposableMixin).Assembly };
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(null, assemblies);

            Assert.That(configuration.ClassContexts.ContainsWithInheritance(typeof(BaseType1)), Is.True);
            Assert.That(configuration.ClassContexts.ContainsWithInheritance(typeof(DisposableMixinTest.C)), Is.True);
        }
Example #2
0
        public void BuildFromAssemblies()
        {
            var assemblies = new[] { typeof(BaseType1).Assembly, typeof(object).Assembly };
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(assemblies);

            Assert.That(configuration.ClassContexts.ContainsWithInheritance(typeof(BaseType1)), Is.True);
            Assert.That(configuration.ClassContexts.ContainsWithInheritance(typeof(object)), Is.False);
        }
        public void DerivedDerivedContext()
        {
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(Assembly.GetExecutingAssembly());
            ClassContext       classContext  = configuration.GetContext(typeof(DerivedDerived));

            Assert.That(classContext, Is.Not.Null);
            Assert.That(classContext.Mixins.ContainsKey(typeof(NullMixin)), Is.True);
            Assert.That(classContext.Mixins.Count, Is.EqualTo(1));
        }
Example #4
0
        public void ClosedGenericClassContext_Closed_NoOwnMixin()
        {
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(Assembly.GetExecutingAssembly());
            ClassContext       classContext  = configuration.GetContext(typeof(GenericClass <string>));

            Assert.That(classContext, Is.Not.Null);
            Assert.That(classContext.Mixins.ContainsKey(typeof(MixinForOpenGeneric)), Is.True);
            Assert.That(classContext.Mixins.Count, Is.EqualTo(1));
        }
Example #5
0
        public void BuildConfigurationFromAssemblies()
        {
            var assemblies = new[] { typeof(TargetClass1).Assembly, typeof(object).Assembly };

            var reflectedOuput = _remotionReflector.BuildConfigurationFromAssemblies(assemblies);
            var expectedOutput = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(assemblies);

            Assert.That(reflectedOuput.To <MixinConfiguration> ().ClassContexts, Is.EqualTo(expectedOutput.ClassContexts));
        }
Example #6
0
        public void MixinAttributeOnMixinClass()
        {
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(Assembly.GetExecutingAssembly());

            ClassContext classContext = configuration.GetContext(typeof(BaseType1));

            Assert.That(classContext, Is.Not.Null);

            Assert.That(classContext.Mixins.ContainsKey(typeof(BT1Mixin1)), Is.True);
        }
Example #7
0
        public void DerivedGenericClassFromOpenContext_Open()
        {
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(Assembly.GetExecutingAssembly());
            ClassContext       classContext  = configuration.GetContext(typeof(DerivedGenericClassFromOpen <>));

            Assert.That(classContext, Is.Not.Null);
            Assert.That(classContext.Mixins.ContainsKey(typeof(MixinForOpenGeneric)), Is.True);
            Assert.That(classContext.Mixins.ContainsKey(typeof(MixinForDerivedOpenGeneric)), Is.True);
            Assert.That(classContext.Mixins.Count, Is.EqualTo(2));
        }
Example #8
0
        public void BuildFromAssemblies_WithParentConfiguration()
        {
            var parentConfiguration = new MixinConfiguration(new ClassContextCollection(ClassContextObjectMother.Create(typeof(object))));

            var assemblies = new[] { typeof(BaseType1).Assembly, typeof(object).Assembly };
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(parentConfiguration, assemblies);

            Assert.That(configuration.ClassContexts.ContainsWithInheritance(typeof(BaseType1)), Is.True);
            Assert.That(configuration.ClassContexts.ContainsWithInheritance(typeof(object)), Is.True);
            Assert.That(configuration.GetContext(typeof(BaseType6)).ComposedInterfaces, Has.Member(typeof(ICBT6Mixin1)));
        }
Example #9
0
        public void ComposedInterfaceConfiguredViaAttribute()
        {
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(Assembly.GetExecutingAssembly());

            ClassContext classContext = configuration.GetContext(typeof(BaseType6));

            Assert.That(classContext, Is.Not.Null);

            Assert.That(classContext.ComposedInterfaces, Has.Member(typeof(ICBT6Mixin1)));
            Assert.That(classContext.ComposedInterfaces, Has.Member(typeof(ICBT6Mixin2)));
            Assert.That(classContext.ComposedInterfaces, Has.Member(typeof(ICBT6Mixin3)));
        }
Example #10
0
        public void MixinAttributeOnTargetClass()
        {
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(Assembly.GetExecutingAssembly());

            ClassContext classContext = configuration.GetContext(typeof(TargetClassWithAdditionalDependencies));

            Assert.That(classContext, Is.Not.Null);

            Assert.That(classContext.Mixins.ContainsKey(typeof(MixinWithAdditionalClassDependency)), Is.True);
            Assert.That(
                classContext.Mixins[typeof(MixinWithAdditionalClassDependency)].ExplicitDependencies, Has.Member(typeof(MixinWithNoAdditionalDependency)));
        }
Example #11
0
        public void DuplicateAssembliesAreIgnored()
        {
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(
                Assembly.GetExecutingAssembly(),
                Assembly.GetExecutingAssembly());

            ClassContext classContext = configuration.GetContext(typeof(BaseType1));

            Assert.That(classContext.Mixins.Count, Is.EqualTo(2));

            Assert.That(classContext.Mixins.ContainsKey(typeof(BT1Mixin1)), Is.True);
            Assert.That(classContext.Mixins.ContainsKey(typeof(BT1Mixin2)), Is.True);
        }
Example #12
0
        public void BuildConfigurationFromAssemblies()
        {
            MixinConfiguration configuration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(Assembly.GetExecutingAssembly());

            Assert.That(configuration.ClassContexts.ContainsWithInheritance(typeof(BaseType1)), Is.True);

            ClassContext contextForBaseType1 = configuration.GetContext(typeof(BaseType1));

            Assert.That(contextForBaseType1.Mixins.Count, Is.EqualTo(2));

            Assert.That(contextForBaseType1.Mixins.ContainsKey(typeof(BT1Mixin1)), Is.True);
            Assert.That(contextForBaseType1.Mixins.ContainsKey(typeof(BT1Mixin2)), Is.True);
        }
Example #13
0
        public void DuplicatesAreIgnored()
        {
            // For some reason, the C# compiler will strip duplicate instances of MixAttribute from the assembly, so in order to test duplicate removal,
            // we need to use generated assemblies.

            var assemblyBuilder1 = DefineDynamicAssemblyWithMixAttribute("Test1", typeof(TargetClassForGlobalMix), typeof(MixinForGlobalMix));
            var assemblyBuilder2 = DefineDynamicAssemblyWithMixAttribute("Test2", typeof(TargetClassForGlobalMix), typeof(MixinForGlobalMix));

            var mixinConfiguration = DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(assemblyBuilder1, assemblyBuilder2);

            ClassContext context = mixinConfiguration.GetContext(typeof(TargetClassForGlobalMix));

            Assert.That(context.Mixins.ContainsKey(typeof(MixinForGlobalMix)), Is.True);
            Assert.That(context.Mixins.Count, Is.EqualTo(1));
        }
Example #14
0
        public void ReMotionApiUsages()
        {
            DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(new Assembly[0]);
            TargetClassDefinitionFactory.CreateAndValidate(null);
            LogManager.GetLogger("");
            Use(new NonApplicationAssemblyAttribute());
            Use(new ConfigurationException(""));
            Use(new ValidationException(new ValidationLogData()));
            Use(typeof(IInitializableMixin));
            Use <TargetClassDefinition> (_ => _.GetMixinByConfiguredType(typeof(object)));
            Use <TargetClassDefinition> (_ => _.GetAllMembers());
            Use <TargetClassDefinition> (_ => _.ImplementedInterfaces);
            Use <TargetClassDefinition> (_ => _.ReceivedInterfaces);
            Use <ClassContext> (_ => _.ComposedInterfaces);
            Use <ClassContext> (_ => _.Mixins);
            Use <MixinDefinition> (_ => _.NextCallDependencies);
            Use <MixinDefinition> (_ => _.TargetCallDependencies);
            Use <MixinDefinition> (_ => _.GetAllOverrides());
            Use <MixinDefinition> (_ => _.AcceptsAlphabeticOrdering);
            Use <MixinDefinition> (_ => _.MixinIndex);
            Use <MixinDefinition> (_ => _.InterfaceIntroductions);
            Use <MixinDefinition> (_ => _.AttributeIntroductions);
            Use <MixinDefinition> (_ => _.TargetClass);
            Use <MixinContext> (_ => _.MixinType);
            Use <MixinContext> (_ => _.ExplicitDependencies);
            Use <MixinContext> (_ => _.MixinKind);
            Use <MixinConfiguration> (_ => _.ClassContexts);
            Use <ClassContextCollection> (_ => _.GetWithInheritance(typeof(object)));
            Use <ValidationException> (_ => _.Data); //TODO: add validationLogData from re-motion 1.15.6
            Use <AttributeIntroductionDefinition> (_ => _.AttributeType);
            Use <InterfaceIntroductionDefinition> (_ => _.InterfaceType);
            Use <MemberDefinitionBase> (_ => _.MemberType);
            Use <MemberDefinitionBase> (_ => _.Name);
            Use <MemberDefinitionBase> (_ => _.MemberInfo);
            Use <MemberDefinitionBase> (_ => _.BaseAsMember);
            Use <MemberDefinitionBase> (_ => _.Overrides);
            Use <MemberDefinitionBase> (_ => _.DeclaringClass);
            Use <ClassDefinitionBase> (_ => _.Type);
            Use <TargetCallDependencyDefinition> (_ => _.RequiredType);
            Use <RequiredTargetCallTypeDefinition> (_ => _.Type);

            //TODO: add SerializableValidationLogData members
        }