public void KnownTypes_FromAssembly_ExcludingNamespace_OpinionIsIndifferent_ReturnsAllTypesOutsideNamespace() { var subject = new DetectTypes(); var indifferentOpinion = new TypeListOpinion( null, null); subject.FromAssemblyContaining<IService>() .ExcludeNamespaceContaining<ICompoundNeed>() .TakeAdviceFrom(indifferentOpinion); var knownTypes = subject.KnownTypes().ToList(); var includedTypes = typeof(IService).Assembly.GetTypes() .Where(type => !type.Namespace.StartsWith( typeof(ICompoundNeed).Namespace)) .ToList(); foreach (var inclusion in includedTypes) { Assert.Contains(inclusion, knownTypes); } }
public void KnownTypes_FromAssembly_ExcludingNamepsace_TypeInNamespaceIncludedBySecondOpinion_ReturnsType() { var inclusions = new[] { typeof(CompoundModule) }; var subject = new DetectTypes(); var inclusionOpinion = new TypeListOpinion( inclusions, null); subject.FromAssemblyContaining<IService>() .ExcludeNamespaceContaining<CompoundModule>() .TakeAdviceFrom(inclusionOpinion); var knownTypes = subject.KnownTypes().ToList(); foreach (var inclusion in inclusions) { Assert.Contains(inclusion, knownTypes); } }
public void KnownTypes_FromAssembly_IncludingNamespace_TypeInNamespaceExcludedBySecondOpinion_DoesNotReturnType() { var exclusions = new[] { typeof(CompoundModule) }; var subject = new DetectTypes(); var exclusionOpinion = new TypeListOpinion( null, exclusions); subject.FromAssemblyContaining<IService>() .IncludeNamespaceContaining<CompoundModule>() .TakeAdviceFrom(exclusionOpinion); var knownTypes = subject.KnownTypes().ToList(); foreach (var exclusion in exclusions) { Assert.DoesNotContain(exclusion, knownTypes); } }