Beispiel #1
0
        public void ClassContextInheritance_Base_FromParentConfiguration()
        {
            MixinConfiguration parentConfiguration =
                new MixinConfigurationBuilder(null).ForClass <NullTarget>().AddMixin(typeof(NullMixin)).BuildConfiguration();
            MixinConfiguration configuration =
                new MixinConfigurationBuilder(parentConfiguration).ForClass <DerivedNullTarget>().AddMixin(typeof(NullMixin2)).BuildConfiguration();
            ClassContext derivedContext = configuration.GetContext(typeof(DerivedNullTarget));

            Assert.That(derivedContext.Mixins.Count, Is.EqualTo(2));
            Assert.That(derivedContext.Mixins.ContainsKey(typeof(NullMixin)), Is.True);
            Assert.That(derivedContext.Mixins.ContainsKey(typeof(NullMixin2)), Is.True);
        }
Beispiel #2
0
        public void ClassContextInheritance_WithOverrides_FromParentConfiguration()
        {
            MixinConfiguration parentConfiguration = new MixinConfigurationBuilder(null)
                                                     .ForClass(typeof(NullTarget)).AddMixin(typeof(NullMixin))
                                                     .ForClass(typeof(GenericTargetClass <>)).AddMixin(typeof(NullMixin))
                                                     .BuildConfiguration();
            MixinConfiguration configuration = new MixinConfigurationBuilder(parentConfiguration)
                                               .ForClass <DerivedNullTarget> ().AddMixin(typeof(DerivedNullMixin))
                                               .ForClass <GenericTargetClass <int> > ().AddMixin(typeof(DerivedNullMixin))
                                               .BuildConfiguration();

            ClassContext derivedContext1 = configuration.GetContext(typeof(DerivedNullTarget));

            Assert.That(derivedContext1.Mixins.Count, Is.EqualTo(1));
            Assert.That(derivedContext1.Mixins.ContainsKey(typeof(DerivedNullMixin)), Is.True);
            Assert.That(derivedContext1.Mixins.ContainsKey(typeof(NullMixin)), Is.False);

            ClassContext derivedContext2 = configuration.GetContext(typeof(GenericTargetClass <int>));

            Assert.That(derivedContext2.Mixins.Count, Is.EqualTo(1));
            Assert.That(derivedContext2.Mixins.ContainsKey(typeof(DerivedNullMixin)), Is.True);
            Assert.That(derivedContext2.Mixins.ContainsKey(typeof(NullMixin)), Is.False);
        }
Beispiel #3
0
        public void ClassContextInheritance_BaseAndTypeDefinition_FromSameConfiguration()
        {
            MixinConfiguration configuration = new MixinConfigurationBuilder(null)
                                               .ForClass <DerivedGenericTargetClass <int> > ().AddMixin(typeof(NullMixin4))
                                               .ForClass(typeof(DerivedGenericTargetClass <>)).AddMixin(typeof(NullMixin))
                                               .ForClass(typeof(GenericTargetClass <int>)).AddMixin(typeof(NullMixin2))
                                               .ForClass(typeof(GenericTargetClass <int>)).AddMixin(typeof(NullMixin3))
                                               .BuildConfiguration();
            ClassContext derivedContext = configuration.GetContext(typeof(DerivedGenericTargetClass <int>));

            Assert.That(derivedContext.Mixins.Count, Is.EqualTo(4));
            Assert.That(derivedContext.Mixins.ContainsKey(typeof(NullMixin)), Is.True);
            Assert.That(derivedContext.Mixins.ContainsKey(typeof(NullMixin2)), Is.True);
            Assert.That(derivedContext.Mixins.ContainsKey(typeof(NullMixin3)), Is.True);
            Assert.That(derivedContext.Mixins.ContainsKey(typeof(NullMixin4)), Is.True);
        }