Search code examples
unit-testingc#-4.0mbunit

passing an object in the attribute of a unit test


how could i pass an object in my unit test? here's my code:

    [Test]          
    [Row( "test",5,new CustomField())]      
    public void Test_Constructor(string type, int number, CustomField customField)
    {
       .....
    }

it returns an error: An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type


Solution

  • You can use a factory:

    http://gallio.org/wiki/doku.php?id=mbunit:data-driven_testing:factory