public void AssemblyScannerUtils_OpenGenerics_ShouldBeFound() { var ls = typeof(List <>).GetInterfaces().ToArray(); var result = AssemblyScannerUtils.FilterImplementationsOfType(typeof(ICollection <>), new[] { typeof(List <>) }).ToList(); Assert.NotEmpty(result); }
public static ConfigurationsScannerResult GetConfigurationFiltered(Type configType) { if (AssemblyScannerUtils.Inherits <IConfigurationBase>(configType)) { var section = Attribute.GetCustomAttribute(configType, typeof(ConfigurationSectionAttribute)) as ConfigurationSectionAttribute; if (section != null) { return(new ConfigurationsScannerResult(configType, section.Section)); } } return(null); }
public void AssemblyScannerUtils_TheοryFilterImplementationOfType_ShouldAgreeWithProvided(Type iface, Type implementation, bool found) { var result = AssemblyScannerUtils.FilterImplementationsOfType(iface, new[] { implementation }).ToList(); if (found) { Assert.NotEmpty(result); Assert.Contains(result, c => c == implementation); } else { Assert.Empty(result); } }
public static ServicesScannerResult GetImplementationsFiltered <T>(Type checkingType, bool includeGivenType = false) where T : IInjectableService { var findType = typeof(T); if (AssemblyScannerUtils.IsImplementationOfType <T>(checkingType)) { var interfaces = checkingType.GetInterfaces() .Where(t => AssemblyScannerUtils.Inherits <T>(t)) .Where(t => includeGivenType || t != findType) .Distinct().ToList(); if (interfaces.Any()) { return(new ServicesScannerResult(checkingType, interfaces)); } } return(null); }
public void AssemblyScannerUtils_ClosedGenerics_ShouldBeFound() { var result = AssemblyScannerUtils.FilterImplementationsOfType <ICollection <string> >(new[] { typeof(List <string>) }); Assert.NotEmpty(result); }
public void AssemblyScannerUtils_InterfaceAsInputAndType_ShouldNotBeFound() { var result = AssemblyScannerUtils.FilterImplementationsOfType <IDisposable>(new[] { typeof(IDisposable) }); Assert.Empty(result); }
public void AssemblyScannerUtils_NoInheritance_ShouldNotBeFound() { var result = AssemblyScannerUtils.FilterImplementationsOfType <IDisposable>(new[] { new object().GetType() }); Assert.Empty(result); }
public void AssemblyScannerUtils_SimpleInheritance_ShouldBeFound() { var result = AssemblyScannerUtils.FilterImplementationsOfType <IDisposable>(new[] { Task.CompletedTask.GetType() }); Assert.Equal(Task.CompletedTask.GetType(), result.Single()); }