Comment 0 for bug 1242315

Revision history for this message
Grzegorz Galezowski (spectral) wrote :

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________!
          }
      }
    }

    public class Class1234
    {
      [Test]
      public void ShouldBEHAVIOR([Any] int a, [Any] string b)
      {
        Assert.Fail("FAILED!");
      }
    }

Best regards,
grzesiek