Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing property setter with arg.any shows warning. #172

Closed
DasOhmoff opened this issue Oct 10, 2021 · 2 comments
Closed

Testing property setter with arg.any shows warning. #172

DasOhmoff opened this issue Oct 10, 2021 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@DasOhmoff
Copy link

Hello, thank you for your support.

If I have the following interface:

public interface ITarget
{
    public float Rotation { get; set; }
}

And the following test code:

ITarget target = Substitute.For<ITarget>();
target.Received().Rotation = Arg.Any<float>(); //Here is the warning

I receive the warning NS1004 - Argument matcher used with a non-virtual member of a class.. My aim is to test whether the rotation of the target got set to anything. Is this warning supposed to be there? Because the property is virtual, is it not (I could be wrong)? Also the code seems to be working if I am not mistaken.

@tpodolak
Copy link
Member

Hi
Arg matcher analyzer has a bug and sometimes it reports false positives. Here are some bug reports which basically cover your issue
#159
#160
Your code is correct so you can safely suppress warning. I will try to publish new version this month (hopefully) so these kind of false positives should be gone

@tpodolak tpodolak added the bug Something isn't working label Oct 10, 2021
@DasOhmoff
Copy link
Author

Ah ok, thank you.

@tpodolak tpodolak added this to the 1.0.15 milestone Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants