You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used all the work around techniques from the thread mentioned but they did not resolve my issue. I had to abandon using NSubstitute in favor of stubs which I really wanted to avoid.
Doubting if this a bug or if we need a support for dynamics. As I don't see any docs about dynamics, I'm tagging this a feature request. But please correct me if wrong.
@304NotModified from #144 (comment) I think we don't have a way to address this. Will close for now; please re-open if anyone knows an implementation that will work for this.
Describe the bug
Get an exception when mocking an interface method that returns a generic collection with a dynamic type.
To Reproduce
The code below cannot execute without throwing an exception, i.e.
Exception thrown: 'NSubstitute.Exceptions.CouldNotSetReturnDueToTypeMismatchException' in NSubstitute.dll
`
public class Demo
{
public interface IAccess
{
Dictionary<string, dynamic>? Execute(string name, Dictionary<string, dynamic>? parameters);
}
}
`
Environment:
Additional context
I have tried casting Dictionary<string, dynamic> to Dictionary<string, object> without success, i.e.
access.Execute(Arg.Any(), null).Returns((Dictionary<string, object>)ret);
as well as,
SubstituteExtensions.Returns(access.Execute(Arg.Any(), null), (Dictionary<string, object>)ret);
The text was updated successfully, but these errors were encountered: