using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Chernobyl.Attribution;
using Chernobyl.Reflection;
using NUnit.Framework;
// The attribute to be tested.
[assembly: ProcessTypes]
namespace Chernobyl.Attribution
{
///
/// Tests for the type.
///
[TestFixture]
public class ProcessTypesAttributeTests : ProcessAttributesTests
{
protected override Test CreateTest()
{
Assembly thisAssembly = Assembly.GetExecutingAssembly();
ProcessTypesAttribute attribute =
thisAssembly.GetCustomAttributes(true).First();
return new Test(attribute, thisAssembly,
new List(new[] {typeof(TestClass1), typeof(TestClass2)}),
TestProcessTypeAttribute.TypesProcessed);
}
}
///
/// Helper type that is used to test
/// and related
/// types.
///
[AttributeUsage(AttributeTargets.Class)]
public class TestProcessTypeAttribute : Attribute, IProcessAttribute
{
static TestProcessTypeAttribute()
{
TypesProcessed = new List();
}
public void Process(Type attributeProvider)
{
TypesProcessed.Add(attributeProvider);
}
public static ICollection TypesProcessed { get; private set; }
}
[TestProcessType]
public static class TestClass2
{}
[TestProcessType]
public class TestClass1
{}
}