コード例 #1
0
        public void TrackDispatcher_InitOffsetTokenDispatcher_InitiateOffsetTokenDispatcher()
        {
            var offsetTokenDispatcher = new OffsetTokenDispatcher();
            var dispatcher            = new TrackDispatcher(offsetTokenDispatcher);

            Assert.AreEqual(dispatcher.OffsetTokenDispatcher, offsetTokenDispatcher);
        }
コード例 #2
0
        /// <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();
        }
コード例 #3
0
        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);
        }