RajOpteamix / moq

Automatically exported from code.google.com/p/moq
Other
0 stars 0 forks source link

System.NullReferenceException on a Callback #222

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I have the following example
__mock.Setup(
                ds => ds.MethodCall(It.IsAny<Interface1>(),
It.IsAny<IResponder<Class1>>()))
                .Callback(
                (Interface1 sheet, IResponder<Class1> responder) =>
                responder.OnSuccess("test"));
but I get the following runtime when running the test:

System.NullReferenceException: Object reference not set to an instance of
an object.
at Moq.Extensions.InvokePreserveStack(Delegate del, Object[] args)
at
Moq.MethodCall.<>c__DisplayClass4.<SetCallbackWithArguments>b__3(Object[] args)
at Moq.MethodCall.Execute(IInvocation call)
at Moq.Interceptor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at IDealServiceProxy5058e5e177ec4c46b94684fe3cafac78.MethodCall(Interface1
i1, IResponder`1 responder)

What is the expected output? What do you see instead?
I expect the callback to be called when the mocked call is intercepted

What version of the product are you using? On what operating system?
Moq.Silverlight.dll 3.1.0.0

Please provide any additional information below.

Original issue reported on code.google.com by gold...@gmail.com on 26 Nov 2009 at 4:54

GoogleCodeExporter commented 8 years ago
If you pass in a null value for your 'responder' parameter, that's basically 
what I'd
expect to see...

Original comment by RoystonS...@googlemail.com on 12 Apr 2010 at 11:31

GoogleCodeExporter commented 8 years ago
precisely. 
can you show the actual test code that exercises that setup?

Original comment by kzu.net on 12 Apr 2010 at 2:01

GoogleCodeExporter commented 8 years ago
Can you send the complete definitions for the interfaces ?

Original comment by marian...@gmail.com on 25 Jun 2010 at 1:47