Exemple #1
0
        public void UnregisterByIdWillFailIfDisposed()
        {
            // Arrange
            var hotKeyId = 0;
            DummyHotKeyManager dummyHotKeyManager = null;

            using (dummyHotKeyManager = new DummyHotKeyManager())
            {
            }

            // Act, Assert
            dummyHotKeyManager.Invoking(hkm => hkm.Unregister(hotKeyId)).Should().Throw <ObjectDisposedException>();
        }
Exemple #2
0
        public void HandleHotKeyWillFailIfDisposed()
        {
            // Arrange
            var hotKeyModifier = HotKeyModifier.Alt | HotKeyModifier.Shift | HotKeyModifier.Control;
            var virtualKeyCode = (UInt32)65; // A
            DummyHotKeyManager dummyHotKeyManager = null;

            using (dummyHotKeyManager = new DummyHotKeyManager())
            {
            }

            // Act, Assert
            dummyHotKeyManager.Invoking(hkm => hkm.HandleHotKey(hotKeyModifier, virtualKeyCode)).Should().Throw <ObjectDisposedException>();
        }
Exemple #3
0
        public void RegisterWillFailIfActionIsNull()
        {
            using (var dummyWindow = DummyWindow.Create())
            {
                using (var dummyHotKeyManager = new DummyHotKeyManager())
                {
                    // Arrange
                    var    hotKeyModifier = HotKeyModifier.Alt | HotKeyModifier.Shift | HotKeyModifier.Control;
                    var    virtualKeyCode = (UInt32)65; // A
                    Action hotKeyAction   = null;

                    // Act, Assert
                    dummyHotKeyManager.Invoking(hkm => hkm.Register(dummyWindow, hotKeyModifier, virtualKeyCode, hotKeyAction)).Should().Throw <ArgumentNullException>();
                }
            }
        }
Exemple #4
0
        public void DisposeWillNotFailIfHotKeyManagerWasAlreadyDisposed()
        {
            using (var dummyWindow = DummyWindow.Create())
            {
                // Arrange
                var    hotKeyModifier  = HotKeyModifier.Alt | HotKeyModifier.Shift | HotKeyModifier.Control;
                var    virtualKeyCode  = (UInt32)65; // A
                var    hotKeyActionSet = false;
                Action hotKeyAction    = () =>
                {
                    hotKeyActionSet = true;
                };

                DummyHotKeyManager dummyHotKeyManager;
                using (dummyHotKeyManager = new DummyHotKeyManager())
                {
                }

                // Act, Assert
                dummyHotKeyManager.Invoking(hkm => hkm.Dispose()).Should().NotThrow <ObjectDisposedException>();
            }
        }