using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Chernobyl.Reflection; using NUnit.Framework; namespace Chernobyl.Attribution { /// /// Tests for the type. /// [TestFixture] public class ProcessMethodsAttributeTests : ProcessAttributesTests { protected override Test CreateTest() { Type testClassType = typeof(TestClass); ProcessMethodsAttribute attribute = testClassType.GetCustomAttributes(true).First(); return new Test(attribute, testClassType, new List(testClassType.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly)), TestProcessMethodAttribute.MethodsProcessed); } } /// /// Helper type that is used to test and /// related types. /// [AttributeUsage(AttributeTargets.Method)] public class TestProcessMethodAttribute : Attribute, IProcessAttribute { static TestProcessMethodAttribute() { MethodsProcessed = new List(); } public void Process(MethodInfo attributeProvider) { MethodsProcessed.Add(attributeProvider); } public static ICollection MethodsProcessed { get; private set; } } [ProcessMethods] public class TestClass { [TestProcessMethod] public void Method1() {} [TestProcessMethod] public void Method2() {} } }