Passing single value to params argument in NUnit TestCase

One way could be to use TestCaseSource, and have a method that returns each parameter set, instead of using TestCase.


Based on this answer in response to the question 'NUnit cannot recognize a TestCase when it contains an array', the compilation error stems from a bug, and can be overcome using the syntax for named test cases, as such:

[ExpectedException(typeof(ParametersParseException))]
[TestCase(new[] { "param1"}, TestName="SingleParam")]
[TestCase(new[] { "param1", "param2"}, TestName="TwoParams")]
[TestCase(new[] { "param1", "param2", "param3", "optParam4", "optParam5"}, "some extra parameter", TestName="SeveralParams")]
public void Parse_InvalidParametersNumber_ThrowsException(params string[] args)
{
    new ParametersParser(args).Parse();
}