Skip to content

Instantly share code, notes, and snippets.

@choffmeister
Created August 5, 2013 12:36
Show Gist options
  • Save choffmeister/6155590 to your computer and use it in GitHub Desktop.
Save choffmeister/6155590 to your computer and use it in GitHub Desktop.
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
namespace NUnitTest
{
[AttributeUsage (AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
public sealed class EnumParameterValueAttribute : ParameterDataAttribute
{
private readonly ICollection _enumValues;
public EnumParameterValueAttribute(Type enumType)
{
_enumValues = Enum.GetValues(enumType);
}
public override IEnumerable GetData(ParameterInfo parameter)
{
return _enumValues;
}
}
public enum TestEnum
{
First,
Second,
Third
}
[TestFixture()]
public class Test
{
[Test()]
public void TestCase([EnumParameterValue(typeof(TestEnum))]TestEnum test, [Values(true, false)]bool value)
{
Assert.AreEqual(TestEnum.First, test);
Assert.IsTrue(value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment