我正在使用 NUnit 3.8.1,我正在尝试做一个非常简单的测试:
[TestCase(0)]
[TestCase(11)]
[TestCase(12)]
[TestCase(13)]
[TestCase(14)]
public void GivenUserCreatesPinWhenItIsInWrongPositionThenThrowArgumentException(uint position)
{
//Assert
Assert.Throws<ArgumentException>(() =>
{
new PositionPin(position);
});
}
Run Code Online (Sandbox Code Playgroud)
我得到这个例外:
消息:System.ArgumentException:“System.Int32”类型的对象无法转换为“System.UInt32”类型
一旦我通过 int 更改 uint 并将 int 转换为 uint 在它工作的方法中。我真的不想这样做,有没有办法保留我的 uint?