public void ExecuteTest(bool isEnabled, bool isServiceable) { var task = new TcoMomentaryTask(); task._enabled.Synchron = isEnabled; task._isServiceable.Synchron = isServiceable; task._setOnRequest.Synchron = false; _logger.ClearLastMessage(); var expected = isEnabled && isServiceable; task.Execute(new object()); Assert.AreEqual(false, task._setOnRequest.Synchron); Assert.IsTrue(_logger.IsLastMessageEmpty()); }
public void ExecuteTest_toggle_false_to_true(bool isEnabled, bool isServiceable) { var task = new TcoToggleTask(); task._enabled.Synchron = isEnabled; task._isServiceable.Synchron = isServiceable; task._toggleRequest.Synchron = false; _logger.ClearLastMessage(); var canExecute = isEnabled && isServiceable; var expected = !task._toggleRequest.Synchron && canExecute; task.Execute(new object()); Assert.AreEqual(expected, task._toggleRequest.Synchron); if (canExecute) { Assert.AreEqual("Task '' toggled 'Off -> On'. {@sender}", _logger.LastMessage.message); Assert.IsInstanceOf <LogInfo>(_logger.LastMessage.payload); Assert.AreEqual("Information", _logger.LastMessage.serverity); } else { Assert.IsTrue(_logger.IsLastMessageEmpty()); } }
public void ValidateCanExecuteAbortRestoreTest_nested_commands(bool serviceable) { var task = new TcoTask(); task._isServiceable.Synchron = serviceable; task._restoreRequest.Synchron = false; task._abortRequest.Synchron = false; _logger.ClearLastMessage(); task.ValidateCanExecuteAbortRestore(null, new Vortex.Connector.ValueTypes.ValueChangedEventArgs(0)); Assert.AreEqual(serviceable, task.Abort.CanExecute(null)); Assert.AreEqual(serviceable, task.Restore.CanExecute(null)); task.Abort.Execute(null); if (serviceable) { Assert.AreEqual("Task '' aborted. {@sender}", _logger.LastMessage.message); Assert.IsInstanceOf <LogInfo>(_logger.LastMessage.payload); Assert.AreEqual("Information", _logger.LastMessage.serverity); } else { Assert.IsTrue(_logger.IsLastMessageEmpty()); } task.Restore.Execute(null); if (serviceable) { Assert.AreEqual("Task '' restored. {@sender}", _logger.LastMessage.message); Assert.IsInstanceOf <LogInfo>(_logger.LastMessage.payload); Assert.AreEqual("Information", _logger.LastMessage.serverity); } else { Assert.IsTrue(_logger.IsLastMessageEmpty()); } Assert.AreEqual(serviceable, task._abortRequest.Synchron); Assert.AreEqual(serviceable, task._restoreRequest.Synchron); }