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 have followed the FakeItEasy documentation to be able to fake internal types, which works for most of my tests. However, when registering a callback to a faked internal event, the callback registration is silently failing, so when the event is later raised then the expected callback is mysteriously not invoked.
As written, this test fails the MustHaveHappened() check. However, if the internal event is changed from internal to public, then the test passes (even while leaving the class itself as internal!).
I have determined the code responsible is in FakeManager.EventRule.cs. In that file, if the call to Type.GetEvents() is changed to specify BindingFlags.NonPublic, and if the calls to EventInfo.GetAddMethod/GetRemoveMethod are changed to pass true for the nonpublic parameter, then the above test passes.
The text was updated successfully, but these errors were encountered:
Thanks, @mriehm. Very nice job reporting and pointing us at the fix.
One thing I should note is that the link you pasted to the docs is actually to what I had thought was a private, non-visible docs build that I'd set up while experimenting with readthedocs. They're quite outdated (but the article you pointed at is close enough to the current behaviour). The official docs are at https://fakeiteasy.readthedocs.io/. I'll see about getting rid of my outdated docs!
I have followed the FakeItEasy documentation to be able to fake internal types, which works for most of my tests. However, when registering a callback to a faked internal event, the callback registration is silently failing, so when the event is later raised then the expected callback is mysteriously not invoked.
Here is a minimal repro:
As written, this test fails the
MustHaveHappened()
check. However, if the internal event is changed from internal to public, then the test passes (even while leaving the class itself as internal!).I have determined the code responsible is in FakeManager.EventRule.cs. In that file, if the call to
Type.GetEvents()
is changed to specifyBindingFlags.NonPublic
, and if the calls toEventInfo.GetAddMethod/GetRemoveMethod
are changed to pass true for thenonpublic
parameter, then the above test passes.The text was updated successfully, but these errors were encountered: