public void Intitialization_WithoutParent() { var builder = new MixinConfigurationBuilder(null); Assert.That(builder.ParentConfiguration, Is.Null); Assert.That(builder.ClassContextBuilders, Is.Empty); MixinConfiguration configuration = builder.BuildConfiguration(); Assert.That(configuration.ClassContexts.Count, Is.EqualTo(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); }
public void BuildConfiguration_IncludesParentConfiguration_WithComposedInterfaces() { var existingClassContext = new ClassContext(typeof(BaseType3), new MixinContext[0], new[] { typeof(IBaseType31) }); var parentConfiguration = new MixinConfiguration(new ClassContextCollection(existingClassContext)); var builder = new MixinConfigurationBuilder(parentConfiguration); MixinConfiguration configuration = builder.BuildConfiguration(); Assert.That(configuration.GetContext(typeof(BaseType3)).ComposedInterfaces, Has.Member(typeof(IBaseType31))); }
public void Intitialization_WithParent() { var parent = new MixinConfiguration(new ClassContextCollection(ClassContextObjectMother.Create(typeof(string)))); var builder = new MixinConfigurationBuilder(parent); Assert.That(builder.ParentConfiguration, Is.SameAs(parent)); Assert.That(builder.ClassContextBuilders, Is.Empty); MixinConfiguration configuration = builder.BuildConfiguration(); Assert.That(configuration.ClassContexts.Count, Is.EqualTo(1)); Assert.That(configuration.ClassContexts.ContainsWithInheritance(typeof(string)), Is.True); }
/// <summary> /// Analyzes the information added so far to this builder and creates a new <see cref="MixinConfiguration"/> from that data. /// </summary> /// <returns>An <see cref="MixinConfiguration"/> derived from the configuration specified in the builder's constructor containing /// <see cref="ClassContext"/> and <see cref="MixinContext"/> objects based on the information added so far.</returns> public MixinConfiguration BuildConfiguration() { s_log.InfoFormat("Building mixin configuration from {0} types.", _allTypes.Count); using (StopwatchScope.CreateScope(s_log, LogLevel.Info, "Time needed to build mixin configuration: {elapsed}.")) { var typeAnalyzers = new IMixinDeclarationAnalyzer <Type>[] { CreateAttributeAnalyzer <Type>(), new HasComposedInterfaceMarkerAnalyzer() }; var assemblyAnalyzers = new IMixinDeclarationAnalyzer <Assembly>[] { CreateAttributeAnalyzer <Assembly> () }; var configurationAnalyzer = new DeclarativeConfigurationAnalyzer(typeAnalyzers, assemblyAnalyzers); var configurationBuilder = new MixinConfigurationBuilder(_parentConfiguration); configurationAnalyzer.Analyze(_allTypes, configurationBuilder); return(configurationBuilder.BuildConfiguration()); } }
public void BuildConfiguration_IncludesParentConfiguration_WithClassContext_Unmodified() { var existingContext = ClassContextObjectMother.Create(typeof(BaseType1), typeof(BT1Mixin1)); var parentConfiguration = new MixinConfiguration(new ClassContextCollection(existingContext)); var builder = new MixinConfigurationBuilder(parentConfiguration); 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.False); }