示例#1
0
        public void TypesThatHaveAttributeFilter()
        {
            var test = (Func <Type, bool>)TypesThat.HaveAttribute(t => t == typeof(SomeAttribute));

            Assert.True(test(typeof(AttributedClass)));
            Assert.False(test(typeof(IntMathService)));
        }
示例#2
0
        public void TypesThatHaveAttributeGeneric()
        {
            var test = (Func <Type, bool>)TypesThat.HaveAttribute <SomeAttribute>();

            Assert.True(test(typeof(AttributedClass)));
            Assert.False(test(typeof(IntMathService)));
        }
示例#3
0
        public void HaveAttributeGeneric()
        {
            Func <Type, bool> haveFilter = TypesThat.HaveAttribute(typeof(SomeTestAttribute));

            Assert.True(haveFilter(typeof(AttributedSimpleObjectA)));

            Assert.False(haveFilter(typeof(AttributedSimpleObjectE)));
        }
示例#4
0
        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)));
        }
示例#5
0
        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)));
        }
示例#6
0
        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());
        }