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

It.IsAny<StructObject>() isn't #1466

Open
MatthewGaraffa opened this issue Mar 21, 2024 · 0 comments
Open

It.IsAny<StructObject>() isn't #1466

MatthewGaraffa opened this issue Mar 21, 2024 · 0 comments
Labels

Comments

@MatthewGaraffa
Copy link

MatthewGaraffa commented Mar 21, 2024

Describe the Bug

It.IsAny<TValue>() doesn't support TValue's of type Struct.

I know this is an issue with the type being a Struct because changing that Struct to a Class allows the test to pass properly.

Steps to Reproduce

stubClass.VerifySet(o => o.Property = It.IsAny<StructObject>(), Times.Once);

Expected Behavior

It.IsAny<StructObject>() should behave the same as any It.IsAny<Class>().

Exception with Stack Trace

System.ArgumentException : Could not determine the correct positions for all argument matchers (1 in total) used in a call to this method: IClass.set_Property.
This could be caused by an unrecognized type conversion, coercion, narrowing, or widening, and is most likely a bug in Moq. Please report your use case to the Moq team.

Stack Trace: 
  ActionObserver.<ReconstructExpression>g__GetArgumentExpressions|0_0[T](Invocation invocation, Match[] matches) line 197
  ActionObserver.ReconstructExpression[T](Action`1 action, Object[] ctorArgs) line 53
  Mock`1.VerifySet(Action`1 setterExpression, Func`1 times) line 1234
  ClassTests.ButtonClick_BadResult_ReturnsFailure() line 51
  RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
  MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

Version Info

Moq 4.20.70, published November 28, 2023

Additional Info

N/A

Back this issue
Back this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant