Ejemplo n.º 1
0
        public void ForClass_Twice()
        {
            var builder = new MixinConfigurationBuilder(null);
            ClassContextBuilder classBuilder  = builder.ForClass(typeof(BaseType1));
            ClassContextBuilder classBuilder2 = builder.ForClass(typeof(BaseType1));

            Assert.That(classBuilder2, Is.SameAs(classBuilder));
        }
        public void Apply(MixinConfigurationBuilder mixinConfigurationBuilder, Type targetClassType)
        {
            ArgumentUtility.CheckNotNull("mixinConfigurationBuilder", mixinConfigurationBuilder);
            ArgumentUtility.CheckNotNull("targetClassType", targetClassType);

            mixinConfigurationBuilder.ForClass(targetClassType).SuppressMixin(MixinToIgnore);
        }
Ejemplo n.º 3
0
        public void Apply(MixinConfigurationBuilder mixinConfigurationBuilder, Type interfaceType)
        {
            ArgumentUtility.CheckNotNull("mixinConfigurationBuilder", mixinConfigurationBuilder);
            ArgumentUtility.CheckNotNull("interfaceType", interfaceType);

            mixinConfigurationBuilder.ForClass(TargetType).AddComposedInterface(interfaceType);
        }
        public void Apply(MixinConfigurationBuilder configurationBuilder, Assembly attributeTarget)
        {
            ArgumentUtility.CheckNotNull("configurationBuilder", configurationBuilder);
            ArgumentUtility.CheckNotNull("attributeTarget", attributeTarget);

            configurationBuilder.ForClass(TargetType).AddMixinDependency(DependentMixin, Dependency);
        }
Ejemplo n.º 5
0
        public void ForClass_Generic()
        {
            var builder = new MixinConfigurationBuilder(null);
            ClassContextBuilder classBuilder = builder.ForClass <BaseType1> ();

            Assert.That(classBuilder.TargetType, Is.SameAs(typeof(BaseType1)));
            Assert.That(classBuilder.Parent, Is.SameAs(builder));
            Assert.That(builder.ClassContextBuilders, Has.Member(classBuilder));
        }
Ejemplo n.º 6
0
        public void BuildConfiguration()
        {
            var builder = new MixinConfigurationBuilder(null);

            builder.ForClass <BaseType1> ();
            MixinConfiguration configuration = builder.BuildConfiguration();

            Assert.That(configuration.ClassContexts.Count, Is.EqualTo(1));
            Assert.That(configuration.ClassContexts.ContainsWithInheritance(typeof(BaseType1)), Is.True);
        }
Ejemplo n.º 7
0
 public void Apply(MixinConfigurationBuilder configurationBuilder, Type attributeTarget)
 {
     try
     {
         configurationBuilder.ForClass(attributeTarget).AddMixin <NullMixin> ();
     }
     catch (Exception ex)
     {
         throw new ConfigurationException(ex.Message, ex);
     }
 }
Ejemplo n.º 8
0
        public void Analyze(Type type, MixinConfigurationBuilder configurationBuilder)
        {
            ArgumentUtility.CheckNotNull("type", type);
            ArgumentUtility.CheckNotNull("configurationBuilder", configurationBuilder);

            var composedInterfaceMarkers = (from ifc in type.GetInterfaces()
                                            where ifc.IsGenericType
                                            let genericTypeDef = ifc.GetGenericTypeDefinition()
                                                                 where genericTypeDef == typeof(IHasComposedInterface <>)
                                                                 let composedInterface = ifc.GetGenericArguments().Single()
                                                                                         where !composedInterface.ContainsGenericParameters
                                                                                         select composedInterface).ToArray();

            if (composedInterfaceMarkers.Length > 0)
            {
                configurationBuilder.ForClass(type).AddComposedInterfaces(composedInterfaceMarkers);
            }
        }
Ejemplo n.º 9
0
        public void BuildConfiguration_IncludesParentConfiguration_WithClassContext_Modified()
        {
            var existingContext     = ClassContextObjectMother.Create(typeof(BaseType1), typeof(BT1Mixin1));
            var parentConfiguration = new MixinConfiguration(new ClassContextCollection(existingContext));

            var builder = new MixinConfigurationBuilder(parentConfiguration);

            builder.ForClass <BaseType1> ().AddMixin <BT1Mixin2> ();

            MixinConfiguration configuration = builder.BuildConfiguration();

            Assert.That(configuration.ClassContexts.Count, Is.EqualTo(1));

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

            Assert.That(classContext, Is.Not.Null);
            Assert.That(classContext.Mixins.ContainsKey(typeof(BT1Mixin1)), Is.True);
            Assert.That(classContext.Mixins.ContainsKey(typeof(BT1Mixin2)), Is.True);
        }