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

Does not support Static Methods with an IEnumerable as an argument #39

Open
Bromoc opened this issue Jan 12, 2018 · 0 comments
Open

Does not support Static Methods with an IEnumerable as an argument #39

Bromoc opened this issue Jan 12, 2018 · 0 comments

Comments

@Bromoc
Copy link

Bromoc commented Jan 12, 2018

context.Setup(
                    () => Utilities.ApplyDivisors( It.IsAny<double>(), It.IsAny<IEnumerable<IDivisor>>() ) )
                    .Returns<double, IEnumerable<IDivisor>>( ( a, b ) => { return a; } );

When executing a Static method that calls ApplyDivisors I get the following exception:

System.InvalidCastException: Object must implement IConvertible.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Smocks.Setups.Setup1.<>c__DisplayClass2_02.b__0(Object[] args)
at Smocks.Setups.Setup1.GetReturnValue(Object[] arguments) at Smocks.Setups.Interceptor.InterceptMethod[TReturnValue](Object[] arguments, MethodBase originalMethod) at Smocks.Setups.Interceptor.Intercept[TReturnValue](Object[] arguments, MethodBase originalMethod) at .... ... Smocks.AppDomains.AppDomainContext.InvokeSerializableLambda[T](SerializableLambda1 serializableFunc, Object target, Object[] arguments)
at Smocks.AppDomains.AppDomainContext.Invoke[T](Action1 action, T parameter) at Smocks.Smock.RunAction(Action1 action, Configuration configuration)
at Smocks.Smock.Run(Configuration configuration, Action1 action) at Smocks.Smock.Run(Action1 action)

If I convert it to a List and create one that converts IEnumerable to List it then works. But i have a constraint that i can not alter the code i am testing.

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

No branches or pull requests

1 participant