static void Main(string[] args)
        {
            Document document = new Document();
            ICommand displayCmd = new DisplayCommand(document);
            ICommand redoCmd = new RedoCommand(document);
            ICommand undoCmd = new UndoCommand(document);

            Invoker invoker = new Invoker(displayCmd, redoCmd, undoCmd);
            invoker.Display();
            invoker.Redo();
            invoker.Undo();
        }
 public UndoCommand(Document document)
 {
     _document = document;
 }
 public DisplayCommand(Document document)
 {
     _document = document;
 }
 public TitleCaseCommand(Document document)
 {
     _document = document;
 }
        public void RunTwoDifferentCommands()
        {
            var menu = new CommandMenu();
            var document = new Document("great expectations");

            menu.AddCommand(TitleCaseMenuText, new TitleCaseCommand(document));
            menu.AddCommand(ToUpperCaseMenuText, new UpperCaseCommand(document));
            menu.Run(TitleCaseMenuText);
            menu.Run(ToUpperCaseMenuText);

            Assert.That(document.Text, Is.EqualTo("GREAT EXPECTATIONS"));
        }
        public void RunSingleCommand()
        {
            var menu = new CommandMenu();
            var document = new Document("great expectations");

            menu.AddCommand(TitleCaseMenuText, new TitleCaseCommand(document));
            menu.Run(TitleCaseMenuText);

            Assert.That(document.Text, Is.EqualTo("Great Expectations"));
        }
 public UpperCaseCommand(Document document)
 {
     _document = document;
 }