コード例 #1
0
ファイル: Tests.cs プロジェクト: fodmar/DesignPatterns
        public void UndoCommand_DontThrowException()
        {
            // Arrange
            string             test     = string.Empty;
            string             expected = "test";
            IExecutor <string> executor = new Executor <string>(test);

            ICommand <string> append = new AppendTextCommand("test");

            // Act
            executor.Do(append);
            executor.Undo(typeof(ToUpperCommand));
            executor.Undo(typeof(ReverseCommand));

            // Assert
            Assert.AreEqual(expected, executor.Target);
        }
コード例 #2
0
ファイル: Tests.cs プロジェクト: fodmar/DesignPatterns
        public void ExecuteCommands()
        {
            // Arrange
            string             test     = string.Empty;
            string             expected = "TSET";
            IExecutor <string> executor = new Executor <string>(test);

            ICommand <string> append  = new AppendTextCommand("test");
            ICommand <string> toUpper = new ToUpperCommand();
            ICommand <string> reverse = new ReverseCommand();

            // Act
            executor.Do(append);
            executor.Do(toUpper);
            executor.Do(reverse);

            // Assert
            Assert.AreEqual(expected, executor.Target);
        }
コード例 #3
0
ファイル: Tests.cs プロジェクト: fodmar/DesignPatterns
        public void RedoCommand()
        {
            // Arrange
            string             test     = string.Empty;
            string             expected = "tset";
            IExecutor <string> executor = new Executor <string>(test);

            ICommand <string> append  = new AppendTextCommand("test");
            ICommand <string> reverse = new ReverseCommand();

            // Act
            executor.Do(append);
            executor.Redo(typeof(AppendTextCommand));
            executor.Undo(typeof(AppendTextCommand));
            executor.Undo(typeof(ReverseCommand));
            executor.Undo(typeof(AppendTextCommand));
            executor.Redo(typeof(AppendTextCommand));
            executor.Do(reverse);

            // Assert
            Assert.AreEqual(expected, executor.Target);
        }