I am using NUnit 3.8.1 and I am trying to do a really simple test:
    [TestCase(0)]
    [TestCase(11)]
    [TestCase(12)]
    [TestCase(13)]
    [TestCase(14)]
    public void GivenUserCreatesPinWhenItIsInWrongPositionThenThrowArgumentException(uint position)
    {
        //Assert
        Assert.Throws<ArgumentException>(() =>
        {
            new PositionPin(position);
        });
    }
And I get this exception:
Message: System.ArgumentException : Object of type 'System.Int32' cannot be converted to type 'System.UInt32'
As soon as I change uint by int and cast the int to uint inside the method it works. I don't really want to do this, is there a way to keep my uint?
Just use an u to directly tell the compiler, that the number is a System.UInt32 number.
[TestCase(0u)]
[TestCase(11u)]
//...
Or: Use int as parameter and cast with (uint)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With