Beispiel #1
0
        public void AssertThatReflectionUtilityCanFindTypeInstancesWithSpecificAttribute()
        {
            // All classes with Letter attribute
            var allTypesWithAttribute = new List <A>
            {
                new B(), new D()
            };

            var reflectionTypesOfAWithAttributeLetter = new List <A>();

            reflectionTypesOfAWithAttributeLetter.AddRange(ReflectionTools
                                                           .GetAllInstancesOfTypeWithAttribute <A, LetterAttribute>());

            Assert.AreEqual(2, reflectionTypesOfAWithAttributeLetter.Count);
            for (var i = 0; i < allTypesWithAttribute.Count; i++)
            {
                Assert.IsTrue(reflectionTypesOfAWithAttributeLetter.Exists(x =>
                                                                           x.GetType() == allTypesWithAttribute[i].GetType()));
            }
        }