public void ListenerHookPointerIsSetToZeroAfterUnregistering()
        {
            var listenerMock = MockRepository.GenerateMock<IHookListener>();
            var controller = new WindowsHookRegistrationController();

            controller.Unregister(listenerMock);

            listenerMock.AssertWasCalled(x => x.HookPointer = IntPtr.Zero,
                                         c => c.Repeat.Once());
        }
        public void ListenerHookPointerIsSetAfterRegistering()
        {
            var listenerMock = MockRepository.GenerateMock<IHookListener>();
            listenerMock.Stub(x => x.HookId).Return((int)WindowsHooks.WH_KEYBOARD_LL);
            var controller = new WindowsHookRegistrationController();

            controller.Register(listenerMock);

            try
            {
                listenerMock.AssertWasCalled(x => x.HookPointer = Arg<IntPtr>.Is.Anything,
                                             c => c.Repeat.Once());
            }
            catch
            {
                throw;
            }
            finally
            {
                controller.Unregister(listenerMock);
            }
        }
 public void UnregisteringNullListenerThrowsException()
 {
     var controller = new WindowsHookRegistrationController();
     Assert.Throws<ArgumentNullException>(() => controller.Unregister(null));
 }