/**
         * Fabricate a result by multiplying the input by 2
         *
         * @param event the <code>IEvent</code> carrying the <code>MacroCommandTestVO</code>
         */
        public override void Execute(INotification note)
        {
            MacroCommandTestVO vo = (MacroCommandTestVO)note.Body;

            // Fabricate a result
            vo.result1 = 2 * vo.input;
        }
        public void MacroCommandExecute()
        {
            // Create the VO
              			var vo = new MacroCommandTestVO(5);

            // Create the Notification (notification)
              			INotification note = new Notification("MacroCommandTest", vo);

            // Create the SimpleCommand
            ICommand command = new MacroCommandTestCommand();

               			// Execute the SimpleCommand
               			command.Execute(note);

               			// test assertions
               			Assert.IsTrue(vo.result1 == 10, "Expecting vo.result1 == 10");
            Assert.IsTrue(vo.result2 == 25, "Expecting vo.result2 == 25");
        }
Esempio n. 3
0
        /**
         * Tests operation of a <code>MacroCommand</code>.
         *
         * <P>
         * This test creates a new <code>Notification</code>, adding a
         * <code>MacroCommandTestVO</code> as the body.
         * It then creates a <code>MacroCommandTestCommand</code> and invokes
         * its <code>execute</code> method, passing in the
         * <code>Notification</code>.<P>
         *
         * <P>
         * The <code>MacroCommandTestCommand</code> has defined an
         * <code>initializeMacroCommand</code> method, which is
         * called automatically by its constructor. In this method
         * the <code>MacroCommandTestCommand</code> adds 2 SubCommands
         * to itself, <code>MacroCommandTestSub1Command</code> and
         * <code>MacroCommandTestSub2Command</code>.
         *
         * <P>
         * The <code>MacroCommandTestVO</code> has 2 result properties,
         * one is set by <code>MacroCommandTestSub1Command</code> by
         * multiplying the input property by 2, and the other is set
         * by <code>MacroCommandTestSub2Command</code> by multiplying
         * the input property by itself.
         *
         * <P>
         * Success is determined by evaluating the 2 result properties
         * on the <code>MacroCommandTestVO</code> that was passed to
         * the <code>MacroCommandTestCommand</code> on the Notification
         * body.</P>
         *
         */
        public void TestMacroCommandExecute()
        {
            // Create the VO
            MacroCommandTestVO vo = new MacroCommandTestVO(5);

            // Create the Notification (note)
            INotification note = new Notification("MacroCommandTest", vo);

            // Create the SimpleCommand
            ICommand command = new MacroCommandTestCommand();

            // Execute the SimpleCommand
            command.Execute(note);

            // test assertions
            Assert.True(vo.result1 == 10, "Expecting vo.result1 == 10");
            Assert.True(vo.result2 == 25, "Expecting vo.result2 == 25");
        }