コード例 #1
0
        public void AssertThatReflectionUtilityCanFindTypesWithSpecificAttribute()
        {
            // All classes with Letter attribute
            var allTypesWithAttribute = new List <Type>
            {
                typeof(B), typeof(D)
            };

            var reflectionTypesOfAWithAttributeLetter = new List <Type>();

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

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