Exemplo n.º 1
0
 public IBusEnvironmentForTest(bool withWindow, bool withIBus)
 {
     ErrorReport.IsOkToInteractWithUser = false;
     wasibusrunning = IBusAdaptor.EngineAvailable;
     if (withIBus)
     {
         if (!IBusAdaptor.StartIBus())
         {
             throw new ApplicationException("Could not start IBus");
         }
     }
     else if (wasibusrunning)
     {
         if (!IBusAdaptor.ExitIBus())
         {
             throw new ApplicationException("Could not stop IBus");
         }
     }
     IBusAdaptor.CloseConnection();
     ShowOncePerSessionBasedOnExactMessagePolicy.Reset();
     if (withWindow)
     {
         CreateWindow();
     }
 }
Exemplo n.º 2
0
        public void DefaultKeyboardName_AfterOpenConnection_ReturnsEnglish()
        {
            IBusAdaptor.EnsureConnection();
            string actual = IBusAdaptor.DefaultKeyboardName;

            Assert.AreEqual(IBusEnvironmentForTest.DefaultKeyboard, actual);             // An assumption.  Should actually be the zeroth element in the list of available keyboards.
        }
Exemplo n.º 3
0
 public void ActivateKeyBoard_IBusNotRunning_ThrowsProblemNotificationSentToUser()
 {
     using (var e = new IBusEnvironmentForTest(true, false))
     {
         Assert.Throws <ErrorReport.ProblemNotificationSentToUserException>(
             () => IBusAdaptor.ActivateKeyboard(IBusEnvironmentForTest.OtherKeyboard)
             );
     }
 }
Exemplo n.º 4
0
 public void Deactivate_IBusNotRunning_DoesNotThrow()
 {
     using (var e = new IBusEnvironmentForTest(true, false))
     {
         Assert.DoesNotThrow(
             () => IBusAdaptor.Deactivate()
             );
     }
 }
Exemplo n.º 5
0
 public void OpenConnection_IBusNotRunning_ThrowsProblemNotificationSentToUser()
 {
     using (var e = new IBusEnvironmentForTest(true, false))
     {
         Assert.Throws <ErrorReport.ProblemNotificationSentToUserException>(
             () => IBusAdaptor.OpenConnection()
             );
     }
 }
Exemplo n.º 6
0
 public void ActivateKeyBoard_IBusDoesNotHaveKeyboard_Throws()
 {
     using (var e = new IBusEnvironmentForTest(true, true))
     {
         Assert.Throws <ArgumentOutOfRangeException>(
             () => IBusAdaptor.ActivateKeyboard("Nonexistent Keyboard")
             );
     }
 }
Exemplo n.º 7
0
 public void ActivateKeyBoard_IBusHasKeyboard_GetCurrentKeyboardReturnsActivatedKeyboard()
 {
     using (var e = new IBusEnvironmentForTest(true, true))
     {
         IBusAdaptor.ActivateKeyboard(IBusEnvironmentForTest.OtherKeyboard);
         string actual = IBusAdaptor.GetActiveKeyboard();
         Assert.AreEqual(IBusEnvironmentForTest.OtherKeyboard, actual);
     }
 }
Exemplo n.º 8
0
 // This will fail because Deactivate does nothing
 public void Deactivate_SwitchesBackToDefaultKeyboard()
 {
     using (var e = new IBusEnvironmentForTest(true, true))
     {
         IBusAdaptor.ActivateKeyboard(IBusEnvironmentForTest.OtherKeyboard);
         IBusAdaptor.Deactivate();
         string actual = IBusAdaptor.GetActiveKeyboard();
         Assert.AreEqual(IBusEnvironmentForTest.DefaultKeyboard, actual);
     }
 }
Exemplo n.º 9
0
 public void Dispose()
 {
     ShowOncePerSessionBasedOnExactMessagePolicy.Reset();
     if (_window != null)
     {
         _window.Close();
         _window.Dispose();
         _window = null;
     }
     IBusAdaptor.CloseConnection();
     if (wasibusrunning)
     {
         IBusAdaptor.StartIBus();
     }
     else
     {
         IBusAdaptor.ExitIBus();
     }
 }