Created
August 5, 2013 12:36
-
-
Save choffmeister/6155590 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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