I have a trivial class only for illustration.
class Foo
{
public static bool Do(int x)
{
return x switch
{
-1 => throw new ApplicationException(),
0 => throw new DivideByZeroException(),
1 => throw new IOException(),
_ => true,
};
}
}
I want to do unit test as follow.
// PSEUDO-CODE
public class FooTest
{
[Theory]
[MemberData(nameof(Data))]
public void DoTest(int x, ... ) // <=========== HERE
{
Assert.Throws<...> (() => Foo.Do(x)); // <=========== HERE
}
public static object[][] Data =
[
[-1, ApplicationException], // <=========== HERE
[0, DivideByZeroException], // <=========== HERE
[1, IOException], // <=========== HERE
[100,true]
];
}
I don’t know what I should write in the lines with comments <=========== HERE
to make the code compilable.