public void TrackDispatcher_InitOffsetTokenDispatcher_InitiateOffsetTokenDispatcher() { var offsetTokenDispatcher = new OffsetTokenDispatcher(); var dispatcher = new TrackDispatcher(offsetTokenDispatcher); Assert.AreEqual(dispatcher.OffsetTokenDispatcher, offsetTokenDispatcher); }
/// <summary> /// Добавить и выполнить команду /// </summary> /// <param name="commandExecutor">Команда</param> public void AddAndExecute(CommandExecutor commandExecutor) { var token = OffsetTokenDispatcher.CreateToken(); if (commands.Contains(token) || undoCommands.Contains(token)) { throw new OffsetTokenLessCurrentExeption(); } commands.Push(new TokenExecutor(commandExecutor, token)); commandExecutor.Execute(); }
public void Offset_RollBackStart_BaseValue() { const int BASE_VALUE = 0; const int CHANGE_VALUE = 1; var offsetTokenDispatcher = new OffsetTokenDispatcher(); var offsetToken = offsetTokenDispatcher.CurrentToken; var dispatcher = new TrackDispatcher(offsetTokenDispatcher); var trackValue = new TrackValue <int>(BASE_VALUE, dispatcher); trackValue.Value = CHANGE_VALUE; dispatcher.Offset(offsetToken); Assert.AreEqual(trackValue.Value, BASE_VALUE); }