-
Notifications
You must be signed in to change notification settings - Fork 264
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
DidNotReceive() and Received() results True if property is sring[] #618
Comments
Hi @KKrzaczek, If you are substituting for a class please make sure the members are Try it with: public class Test
{
public virtual string[] Content { get; set; }
} Installing NSubstitute.Analyzers can help detect problems like this and suggest fixes. |
Thank you for the suggestion, it helps me. In my opinion it should throw exception (ex. NotSupportedException, when a test is executed on non-virtual properties). |
@KKrzaczek Unfortunately, due to technical limitations NSubstitute simply cannot detect calls to non-virtual members. That's why we suggest installation of analyzers to cover our blind spots. Closing the issue as there is nothing more we can do. Please let us know if you need further help. |
Thanks @zvirja! 😄I don't think I'm exaggerating to recommend that the C# or VB analyzers should be installed whenever someone installs the NSubstitute package. @KKrzaczek, the analyzers will do one better than throwing a |
@dtchepak Let's plan that for v5, as we discussed before. So that we have structure like xUnit - |
Describe the bug
Test should fail but its not.
To Reproduce
public class Test
{
public string[] Content { get; set; }
}
[Fact]
public void Should_What()
{
var obj = Substitute.For();
var test = obj.DidNotReceive().Content;
var test2 = obj.Received().Content;
}
Expected behaviour
I will be able to test property Content has been used
Environment:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: