我正在尝试测试一个非常简单的功能。它返回包含一些指定数字的数字。如果第一个参数是null,它将抛出ArgumentNullException。
不幸的是,Assert.Throws据说没有抛出预期的异常并且测试失败。当我尝试调试测试时,它不会进入我的方法。与相同ArgumentException。
仅最后两个测试失败,其他测试成功。
我要测试的功能:
/// <summary>
/// Filter given numbers and return only numbers containing the specified digit.
/// </summary>
/// <param name="numbers">The numbers to be filtered.</param>
/// <param name="digit">The digit which should be found.</param>
/// <returns>Numbers that contains the digit.</returns>
/// <exception cref="ArgumentException"> Thrown if the digit value isn't between 0 and 9.</exception>
/// <exception cref="ArgumentNullException"> Thrown if numbers are null.</exception>
public static IEnumerable<int> FilterDigits(IEnumerable<int> numbers, byte digit)
{
if (numbers …Run Code Online (Sandbox Code Playgroud)