コード例 #1
0
        public void EnablingChangesIsEnabledToTrue()
        {
            var registrationControllerMock = MockRepository.GenerateMock<IHotKeyRegistrationController>();
            registrationControllerMock.Stub(x => x.Register(Arg<IHotKey>.Is.Anything)).Return(0);
            var hotKey = new HotKey(registrationControllerMock);
            hotKey.Key = System.Windows.Forms.Keys.A;

            Assert.IsFalse(hotKey.IsEnabled);
            hotKey.Enable();
            Assert.IsTrue(hotKey.IsEnabled);
        }
コード例 #2
0
        public void IdIsSetToControllerProvidedValueWhenHotKeyIsEnabled()
        {
            var id = 15;
            var registrationControllerMock = MockRepository.GenerateMock<IHotKeyRegistrationController>();
            registrationControllerMock.Stub(x => x.Register(Arg<IHotKey>.Is.Anything)).Return(id);
            var hotKey = new HotKey(registrationControllerMock);
            hotKey.Key = System.Windows.Forms.Keys.A;

            Assert.AreNotEqual(id, hotKey.Id);
            hotKey.Enable();
            Assert.AreEqual(id, hotKey.Id);
        }
コード例 #3
0
 public void EnablingHotKeyWithoutKeySetThrowsException()
 {
     var registrationControllerMock = MockRepository.GenerateMock<IHotKeyRegistrationController>();
     var hotKey = new HotKey(registrationControllerMock);
     Assert.Throws<ArgumentException>(() => hotKey.Enable());
 }