Skip to content

Instantly share code, notes, and snippets.

@hmemcpy
Last active January 1, 2016 23:48
Show Gist options
  • Save hmemcpy/8218569 to your computer and use it in GitHub Desktop.
Save hmemcpy/8218569 to your computer and use it in GitHub Desktop.
AcountProvider provider = AccountProvider.CreateProvider();
AcountProvider outProvider;
A.CallTo(() => mockAppointment.GetAccountCollection().GetProviderImpl(out outProvider)) // GetProviderImpl is a generic method
.Returns(true)
.AssignsOutAndRefParameters(provider);
bool result = mockAppointment.GetAccountCollection().GetProviderImp(out outProvider); // this returns false and provider is null???
@adamralph
Copy link

things that spring to mind:-

  • mockAppointment is presumably your fake. it may be worth configuring mockAppointment.GetAccountCollection() to return another of your own fakes and then configuring fakeAccountCollection.GetProviderImpl(out provider) separately
  • you mentioned that GetProviderImpl is generic, does specifying the type parameter explicitly help (I guess it shouldn't)
  • I can't remember how argument matching works in this case, but it may be worth trying to pass a separate uninitialised provider variable in the A.CallTo() expression. That would work assuming that your SUT also passes an uninitialised variable to the call

@hmemcpy
Copy link
Author

hmemcpy commented Jan 2, 2014

Well, extracting a separate fake for IAccountCollectionProvider did the trick! Odd, I'm sure I tried it first... Anyway, I'll open an issue later, if this really turns out to be a bug!

Thanks!

@adamralph
Copy link

No probs.

I remember the details now. This is actually by design. Unconfigured fake methods return a new instance each time and unconfigured fake properties return the same instance each time. Excruciating detail can be found in this conversation FakeItEasy/FakeItEasy#156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment