The following code works fine with NUnit test adapter (VS 2012, nunit 2.6.2):
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] public class AnyAttribute : ParameterDataAttribute { public override IEnumerable GetData(ParameterInfo parameter) { if (parameter.ParameterType == typeof(int)) { return new[] { 122 }; } else { return new[] { "a" }; } } }
public class Class1234 { [Test] public void ShouldBEHAVIOR([Any] int a, [Any] string b) { Assert.Fail("FAILED!"); } }
But the following does not (although it works just fine in gui standalone nunit runner) and VS Test Runner marks the test as not run:
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] public class AnyAttribute : ParameterDataAttribute { public override IEnumerable GetData(ParameterInfo parameter) { if (parameter.ParameterType == typeof(int)) { return new[] { 122 }; } else { return new[] { "a" + new Random().Next() }; //______ONLY CHANGE________! } } }
Best regards, grzesiek
The following code works fine with NUnit test adapter (VS 2012, nunit 2.6.2):
[AttributeU sage(AttributeT argets. Parameter, AllowMultiple = false, Inherited = false)] tribute ParameterInfo parameter) ParameterType == typeof(int))
public class AnyAttribute : ParameterDataAt
{
public override IEnumerable GetData(
{
if (parameter.
{
return new[] { 122 };
}
else
{
return new[] { "a" };
}
}
}
public class Class1234 [Any] int a, [Any] string b)
Assert. Fail("FAILED! ");
{
[Test]
public void ShouldBEHAVIOR(
{
}
}
But the following does not (although it works just fine in gui standalone nunit runner) and VS Test Runner marks the test as not run:
[AttributeU sage(AttributeT argets. Parameter, AllowMultiple = false, Inherited = false)] tribute ParameterInfo parameter) ParameterType == typeof(int))
public class AnyAttribute : ParameterDataAt
{
public override IEnumerable GetData(
{
if (parameter.
{
return new[] { 122 };
}
else
{
return new[] { "a" + new Random().Next() }; //______ONLY CHANGE________!
}
}
}
public class Class1234 [Any] int a, [Any] string b)
Assert. Fail("FAILED! ");
{
[Test]
public void ShouldBEHAVIOR(
{
}
}
Best regards,
grzesiek