-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
Expected invocation on the mock should never have been performed, but was 1 times. when upgrading to the latest moq version 4.16.1 from 4.10.0 #1168
Labels
Comments
aniketiitg
changed the title
I faced a similar issue when upgrading to the latest moq version 4.16.1 from 4.10.0
Expected invocation on the mock should never have been performed, but was 1 times. when upgrading to the latest moq version 4.16.1 from 4.10.0
Jun 4, 2021
Test code:using Moq;
using Xunit;
public class Tests
{
[Fact]
public void Test()
{
var serviceMock = new Mock<IService>();
serviceMock.Object.SomeMethod(null);
serviceMock.Verify(x => x.SomeMethod(It.IsAny<string>()), Times.Never);
}
}
public interface IService
{
void SomeMethod(string str);
} Outcome with Moq 4.10.0
Outcome with Moq 4.16.1
ConclusionWhile the error message format has changed a little, I cannot confirm your claim that there has been a fundamental change in behavior between versions 4.10.0 and 4.16.1 regarding whether or not What am I missing? |
Closing due to missing feedback. We cannot proceed without a repro. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I faced a similar issue when upgrading to the latest moq version 4.16.1 from 4.10.0
Earlier - the verify() of a method with "It.IsAny<string>()", when invoked with parameter null -> This scenario was considered Negative.
serviceMock.Verify(x => x.SomeMethod(<It.IsAny<string>()), Times.Never)
passes when -
SomeMethod(null)
Now with the current version 4.16.1, passing null, the verify considers it as positive.
SomeMethod(null) ->Expected invocation on the mock should never have been performed, but was 1 times.
@stakx - any idea related to this would help.
Originally posted by @aniketiitg in #1055 (comment)
The text was updated successfully, but these errors were encountered: