private static void ProcessExclusionAttributes(Assembly assembly) { // Check for invocation helpers. var assistAttributes = assembly.GetCustomAttributes(typeof(Xunit.Extensions.InstantiateInstanceDataAttribute), inherit: false); foreach (Xunit.Extensions.InstantiateInstanceDataAttribute attribute in assistAttributes) { InstanceCreator.InstanceDataInvoker = (IInstantiateInstanceData)Activator.CreateInstance(attribute.InstantiatorType); } // Check for excluded types. var limitAttributes = assembly.GetCustomAttributes(typeof(Xunit.Extensions.LimitInstanceDataAttribute), inherit: false); foreach (Xunit.Extensions.LimitInstanceDataAttribute attribute in limitAttributes) { TypeCreator.LimitInstances(attribute.TargetType, attribute.AvailableTypes); } // Check for excluded assemblies. var excludeAttributes = assembly.GetCustomAttributes(typeof(Xunit.Extensions.ExcludeAssemblyAttribute), inherit: false); foreach (Xunit.Extensions.ExcludeAssemblyAttribute attribute in excludeAttributes) { excludedAssemblies_.Add(attribute.AssemblyName); } // Reset any excluded examined assemblies. foreach (Assembly excluded in types_.Keys.Where(IsExcludedAssembly).ToArray( )) { types_[excluded] = Type.EmptyTypes; } }
public void GetCreators_returns_expected_collection_for_limited_type( ) { TypeCreator.LimitInstances(typeof(LimitedType), typeof(FactoryLimitedType)); var creators = TypeCreator.GetCreators(typeof(LimitedType)); Assert.Equal(1, creators.Count); }
public void GetCreators_returns_normal_collection_for_type_derived_from_excluded_type( ) { TypeCreator.LimitInstances(typeof(ExcludedType)); var creators = TypeCreator.GetCreators(typeof(DerivedExcludedType)); Assert.NotEmpty(creators); }
public void GetCreators_returns_empty_collection_for_excluded_type( ) { TypeCreator.LimitInstances(typeof(ExcludedType)); var creators = TypeCreator.GetCreators(typeof(ExcludedType)); Assert.Empty(creators); }