Does it have to be a StrictMock for your unit test? I tried a quick sample using MockRepository.GenerateMock and it worked fine:
var whateverProvider = MockRepository.GenerateMock<IWhateverProvider>(); var someParam = new CustomMetric(); dynamic suppliedExpando = this; whateverProvider.Stub(w => w.FlattenTree(someParam)).Return(suppliedExpando); var result = whateverProvider.FlattenTree(someParam); I also tried it with GenerateStub and the call to FlattenTree worked. --- Patrick Steele http://weblogs.asp.net/psteele On Thu, Nov 3, 2011 at 8:37 PM, DougLoyo <[email protected]> wrote: > Hi Ayende, > > Love your work man, you have given so much to the community. > > Quick question: > I have the following Interface: > public interface IWhateverProvider > { > dynamic FlattenTree(CustomMetric metricTreeRootNode); > } > > I mock it: > whateverProvider = mocks.StrictMock<IWhateverProvider>(); > > Then I set expected calls: > Expect.Call(whateverProvider.FlattenTree(someParam)).Return(suppliedExpando); > > This Compiles but on execution of my test it blows up: > SetUp : Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : The > best overloaded method match for > 'Rhino.Mocks.Impl.MethodOptions<ObjectProxy4705c172f1b74c6595666798e50959a3>.Return(ObjectProxy4705c172f1b74c6595666798e50959a3)' > has some invalid arguments > at CallSite.Target(Closure, CallSite, Object, Object) > at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2(CallSite site, > T0 arg0, T1 arg1) > at > When_invoking_the_Service_Get_method.EstablishContext(MockRepository > mocks) in ServiceFixture.cs: line 63 > at Testing.TestFixtureBase.RunOnceBeforeAny() in TestFixtureBase.cs: > line 25 > > Any Ideas? > > Thanks, > Douglas > > -- > You received this message because you are subscribed to the Google Groups > "Rhino.Mocks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rhinomocks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
