Ejemplo n.º 1
0
        public void HaveAttributeGeneric()
        {
            Func <Type, bool> haveFilter = TypesThat.HaveAttribute(typeof(SomeTestAttribute));

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

            Assert.False(haveFilter(typeof(AttributedSimpleObjectE)));
        }
Ejemplo n.º 2
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)));
        }
Ejemplo n.º 3
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)));
        }
Ejemplo n.º 4
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());
        }