ArgumentException after upgrading from Moq 4.10.1 to 4.11 (and later)
See original GitHub issueI have a mock that is created, using Autofixture.Moq
nuget package, with:
var fixture = new Fixture();
fixture.Customize(new AutoMoqCustomization());
var myMock = fixture.Create<IMyInterface>()
That was working with Moq 4.10.1 but no more with Moq 4.11 and later.
But now, when calling a method on this mock, I’ve got the exception:
System.ArgumentException
Argument types do not match
at ConstantExpression System.Linq.Expressions.Expression.Constant(object value, Type type)
at void Moq.Mock.AddInnerMockSetup(Invocation invocation, object returnValue)
at void Moq.Return.Handle(Invocation invocation, Mock mock)
at void Castle.DynamicProxy.AbstractInvocation.Proceed()
at Dictionary<int, CategoryResult[]> Castle.Proxies.ICoreServiceProxy.GetCategoryResultsFormattedForEntity(out long cacheRevision, Nullable<int> idAnalysis, int entityID, List<AttributeAndFormat> attributes, int beginPeriod, int endPeriod, Periodicity periodicitySelected, bool ignoreOutOfBounds, TalianceToken talianceToken, Nullable<int> idSnapshot)
Could you give me a clue from where the problem could come from?
I’m not really sure if it’s a AutoFixture.Moq
problem (and need an update with newer moq
releases) or a Moq
regression… So including @stakx in the report.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Moq Verify Not Working as Expected After Upgrading to . ...
After upgrading to .NET Core 3.1 and Moq Version 4.14.5, the verify method is failing saying the method specified hasn't been called (no...
Read more >Moq/CHANGELOG and Moq Releases (Page 4) | LibHunt
After updating Moq from 4.10.1 to 4.11, mocking NHibernate session throws a System.NullReferenceException (@ronenfe, #955) ...
Read more >Moq
ArgumentException : No protected method HasMethodWithRefParameter.RefMethod found whose signature is compatible with the provided arguments (int). mock.
Read more >Firebase Apple SDK Release Notes - Google
Added a new dynamic property wrapper API that enables developers to configure UI components to automatically update when new configs are activated. (#10155) ......
Read more >2020-July.txt
- CVE-2020-15025: Fixed an issue which remote attacker could have caused denial of service by consuming the memory when a CMAC key was...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Giving another quick try to update from “4.10.1” to “4.16.0” and
AutoFixture.AutoMoq
from “4.11.0” to"4.15.0" and I still have the problem.I have a better stacktrace:
I don’t have a good understanding because that’s a big dirty test (not unit at all!!) but the behavior change is still there. I have to figure it out what is the real problem but that will require more investigation…
@jzabroski I have reproduced the setup from the original post with the latest AutoFixture and I could not reproduce the failure. I used a .NET Framework unit test project with the following dependencies.
The following test fails.
Closing this issue. If anyone finds a reproducible example, feel free to reopen the issue.