public void TypesThatHaveAttributeFilter() { var test = (Func <Type, bool>)TypesThat.HaveAttribute(t => t == typeof(SomeAttribute)); Assert.True(test(typeof(AttributedClass))); Assert.False(test(typeof(IntMathService))); }
public void TypesThatHaveAttributeGeneric() { var test = (Func <Type, bool>)TypesThat.HaveAttribute <SomeAttribute>(); Assert.True(test(typeof(AttributedClass))); Assert.False(test(typeof(IntMathService))); }
public void HaveAttributeGeneric() { Func <Type, bool> haveFilter = TypesThat.HaveAttribute(typeof(SomeTestAttribute)); Assert.True(haveFilter(typeof(AttributedSimpleObjectA))); Assert.False(haveFilter(typeof(AttributedSimpleObjectE))); }
public void HaveAttributeGenericFiltered() { Func <Type, bool> haveFilter = TypesThat.HaveAttribute <SomeTestAttribute>(x => x.TestValue == 5); Assert.True(haveFilter(typeof(AttributedSimpleObjectA))); Assert.False(haveFilter(typeof(AttributedSimpleObjectB))); Assert.False(haveFilter(typeof(AttributedSimpleObjectE))); }
public void HaveAttributeTypeFiltered() { Func <Type, bool> haveFilter = TypesThat.HaveAttribute(typeof(SomeTestAttribute), x => ((SomeTestAttribute)x).TestValue == 5); Assert.True(haveFilter(typeof(AttributedSimpleObjectA))); Assert.False(haveFilter(typeof(AttributedSimpleObjectB))); Assert.False(haveFilter(typeof(AttributedSimpleObjectE))); }
public void ComplexHaveAttributeNonGeneric() { var container = new DependencyInjectionContainer(); container.Configure(c => c.Export(typeof(TypesThatTests).GetTypeInfo().Assembly.ExportedTypes). ByInterface(typeof(IAttributedSimpleObject)). Where(TypesThat.HaveAttribute(t => t == typeof(SomeTestAttribute)))); IEnumerable <IAttributedSimpleObject> simpleObjects = container.LocateAll <IAttributedSimpleObject>(); Assert.NotNull(simpleObjects); Assert.Equal(3, simpleObjects.Count()); }