void when_the_hook_is_called()
{
before = () =>
{
_notifier = new ReflectionDetourNotifier(HookFactory, _subject.Managed);
_notifier.Hook.Apply();
};
act = () => _result = _subject.Managed(2.0);
context["and the return value is modified in an event handler"] = () =>
{
before = () => _notifier.DetourCalled += (s, e) => e.ReturnValue = ExpectedValue;
it["should return the modified value"] = () => _result.should_be(ExpectedValue);
it["should call the original"] = () => _subject.WasManagedCalled.should_be_true();
};
context["and the original shall not be called"] = () =>
{
before = () => _notifier.DetourCalled += (s, e) =>
{
e.CallOriginal = false;
e.ReturnValue = ExpectedValue;
};
it["should not call the original"] = () => _subject.WasManagedCalled.should_be_false();
};
after = () => _notifier.Dispose();
}