Пример #1
0
        public void BuildConfiguration_Duplicates_NotIgnoredInGeneral()
        {
            var builder = new DeclarativeConfigurationBuilder(null);

            builder.AddType(typeof(TypeWithDuplicateAttributeNotIgnoringDuplicates));

            Assert.That(() => builder.BuildConfiguration(), Throws.TypeOf <ConfigurationException>().With.Message.StringContaining("already configured"));
        }
        private MixinConfiguration GetMixinConfiguration(ICollection typesToBeAnalyzed)
        {
            DeclarativeConfigurationBuilder builder = new DeclarativeConfigurationBuilder(null);

            foreach (Type type in typesToBeAnalyzed)
            {
                builder.AddType(type);
            }

            return(builder.BuildConfiguration());
        }
        protected void PrepareMixinConfigurationWithAttributeDeclarations(params AdditionalMixinDependencyAttribute[] attributes)
        {
            var assemblyWithDeclarations = CreateAssemblyWithAdditionalAttributeDeclarations(attributes);

            var builder = new DeclarativeConfigurationBuilder(null);

            builder.AddAssembly(GetType().Assembly);
            builder.AddAssembly(assemblyWithDeclarations);

            MixinConfiguration.SetActiveConfiguration(builder.BuildConfiguration());
        }
Пример #4
0
        public void BuildConfiguration_Duplicates_IgnoredIfIndicatedByAttribute()
        {
            var builder = new DeclarativeConfigurationBuilder(null);

            builder.AddType(typeof(TypeWithDuplicateAttributeIgnoringDuplicates1));
            builder.AddType(typeof(TypeWithDuplicateAttributeIgnoringDuplicates2));

            var configuration = builder.BuildConfiguration();

            Assert.That(configuration.GetContext(typeof(TypeWithDuplicateAttributeIgnoringDuplicates1)).Mixins, Has.Count.EqualTo(1));
            Assert.That(configuration.GetContext(typeof(TypeWithDuplicateAttributeIgnoringDuplicates2)), Is.Null, "Ignored attributes - no mixins.");
        }
Пример #5
0
        public void BuildConfiguration_WithParentConfiguration()
        {
            MixinConfiguration parentConfiguration = MixinConfiguration.BuildNew().ForClass <int>().AddMixin <string>().BuildConfiguration();
            var builder = new DeclarativeConfigurationBuilder(parentConfiguration);

            builder.AddType(typeof(User));

            MixinConfiguration configuration = builder.BuildConfiguration();
            ClassContext       c1            = new ClassContextBuilder(typeof(User)).AddMixin(typeof(NullMixin)).OfKind(MixinKind.Used).BuildClassContext();

            Assert.That(configuration.ClassContexts,
                        Is.EquivalentTo(new object[] { c1, parentConfiguration.GetContext(typeof(int)), _globalClassContext }));
        }
        public void DerivedDerivedContextWithOwnMixin_Order2()
        {
            var builder = new DeclarativeConfigurationBuilder(null);

            builder.AddType(typeof(DerivedDerivedWithOwnMixin));
            builder.AddType(typeof(Derived));
            builder.AddType(typeof(Base));

            MixinConfiguration configuration = builder.BuildConfiguration();
            ClassContext       classContext  = configuration.GetContext(typeof(DerivedDerivedWithOwnMixin));

            Assert.That(classContext, Is.Not.Null);
            Assert.That(classContext.Mixins.ContainsKey(typeof(NullMixin)), Is.True);
            Assert.That(classContext.Mixins.ContainsKey(typeof(NullMixin2)), Is.True);
            Assert.That(classContext.Mixins.Count, Is.EqualTo(2));
        }