示例#1
0
        public void Test()
        {
            var receiver = new Receiver();
            Command command = new ConcreteCommand(receiver);
            var invoker = new Invoker(command);

            Assert.That(receiver.HasBeenInvoked, Is.False);

            invoker.Invoke();

            Assert.That(receiver.HasBeenInvoked, Is.True);
        }
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        private static void Main()
        {
            // Create receiver, command, and invoker
              Receiver receiver = new Receiver();
              Command command = new ConcreteCommand(receiver);
              Invoker invoker = new Invoker();

              // Set and execute command
              invoker.SetCommand(command);
              invoker.ExecuteCommand();

              // Wait for user
              Console.ReadKey();
        }
示例#3
0
            /// <summary>
            /// Entry point into console application.
            /// </summary>
            public static void Main()
            {
                // Create receiver, command, and invoker

                Receiver receiver = new Receiver();
                Command  command  = new ConcreteCommand(receiver);
                Invoker  invoker  = new Invoker();

                // Set and execute command

                invoker.SetCommand(command);
                invoker.ExecuteCommand();

                // Wait for user

                Console.ReadKey();
            }