Follow-up to a great docs observation on nunit/docs#750 and nunit/nunit.analyzers#533
The Is.AnyOf only works if the members are specified as individual values, not if passed as an array or list.
Example Gotcha:
[Test]
public void CanBeUsedWithParameters()
{
Assert.That(42, Is.AnyOf(0, -1, 42, 100)); // Passes
}
[Test]
public void CantBeUsedWithAnArray()
{
var array = new[] { 0, -1, 42, 100 };
Assert.That(42, Is.AnyOf(array)); // Fails
}
[Test]
public void CantBeUsedWithAList()
{
var list = new List<int>() { 0, -1, 42, 100 };
Assert.That(42, Is.AnyOf(list)); // Fails
}
It was suggested to make an Analyzer to warn about this, but it seems more prudent to fix it in the framework, so that these expected cases work.
Follow-up to a great docs observation on nunit/docs#750 and nunit/nunit.analyzers#533
The
Is.AnyOfonly works if the members are specified as individual values, not if passed as an array or list.Example Gotcha:
It was suggested to make an Analyzer to warn about this, but it seems more prudent to fix it in the framework, so that these expected cases work.