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 ProcessParametersAttributeTests : ProcessAttributesTests { protected override Test CreateTest() { const string method1 = "Method1"; MethodInfo testMethodInfo = typeof(TestParamClass).GetMethod(method1); ProcessParametersAttribute attribute = testMethodInfo.GetCustomAttributes(true).First(); return new Test(attribute, testMethodInfo, new List(testMethodInfo.GetParameters()), TestReturnProcessParameterAttribute.MethodsProcessed); } } /// /// Helper type that is used to test and /// related types. /// [AttributeUsage(AttributeTargets.Parameter)] public class TestReturnProcessParameterAttribute : Attribute, IProcessAttribute { static TestReturnProcessParameterAttribute() { MethodsProcessed = new List(); } public void Process(ParameterInfo attributeProvider) { MethodsProcessed.Add(attributeProvider); } public static ICollection MethodsProcessed { get; private set; } } public class TestParamClass { [ProcessParameters] public void Method1([TestReturnProcessParameter]int x, [TestReturnProcessParameter]string y) { } } }