-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
MissingMethodException when Verify Method with Array of ValueTuple #1154
Comments
I cannot reproduce the error you're reporting: using Moq;
var mock = new Mock<ILogger>();
mock.Verify(m => m.Fatal(It.IsAny<string>(), It.IsAny<(string Name, object Value)[]>()), Times.Once);
public interface ILogger
{
void Fatal(string message, params (string Name, object Value)[] attributes);
} When run, the above program causes the following exception (as it should):
Please provide complete, but minimal repro code; otherwise I'm going to close this issue in a few days' time. |
@stakx thanks for the quick reply. I appreciate you trying this out and the fact you couldn't reproduce is valuable information. In trying to create a minimal repo code, somehow the error disappeared for me too. I will dig a bit deeper and try and work out what exactly is causing the exception. |
@stakx it turns out that the reason I was getting this error, was because the NuGet package <configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
...
</assemblyBinding>
</runtime>
</configuration> After I removed the assembly binding redirect from the app.config it all worked fine. However, just to make sure I also uninstalled the NuGet package as well since I believe ValueTuples are now built-in right? Thanks again for your help. |
To be honest, I'm not sure if you actually support this, but here is what I am trying to do:
I have a logger class that I want to mock and it has a method
Fatal
that I would like to verify. I am having trouble matching the method signature and I think it is because it takes an array of ValueTuples.Here is what I tried:
This compiles, but when I run my unit test it throws the
MissingMethodException
exception.The text was updated successfully, but these errors were encountered: