/**
         * Fabricate a result by multiplying the input by 2
         *
         * @param note the Notification carrying the FacadeTestVO
         */
        override public void Execute(INotification note)
        {
            FacadeTestVO vo = (FacadeTestVO)note.Body;

            // Fabricate a result
            vo.result = 2 * vo.input;
        }
Ejemplo n.º 2
0
        public void RegisterCommandAndNotifyObservers()
        {
            // Create the Facade, register the FacadeTestCommand to
            // handle 'FacadeTest' events
            IFacade facade = Facade.Instance;

            facade.RegisterCommand("FacadeTestNote", typeof(FacadeTestCommand));

            // Send notification. The Command associated with the event
            // (FacadeTestCommand) will be invoked, and will multiply
            // the vo.input value by 2 and set the result on vo.result
            var vo = new FacadeTestVO(32);

            facade.SendNotification("FacadeTestNote", vo);

            // test assertions
            Assert.IsTrue(vo.result == 64, "Expecting vo.result == 64");
        }
Ejemplo n.º 3
0
        /**
         * Tests Command removal via the Facade.
         *
         * <P>
         * This test gets the Singleton Facade instance
         * and registers the FacadeTestCommand class
         * to handle 'FacadeTest' Notifcations. Then it removes the command.<P>
         *
         * <P>
         * It then sends a Notification using the Facade.
         * Success is determined by evaluating
         * a property on an object placed in the body of
         * the Notification, which will NOT be modified by the Command.</P>
         *
         */
        public void TestRegisterAndRemoveCommandAndSendNotification()
        {
            // Create the Facade, register the FacadeTestCommand to
            // handle 'FacadeTest' events
            IFacade facade = Facade.Instance;

            facade.RegisterCommand("FacadeTestNote", typeof(FacadeTestCommand));
            facade.RemoveCommand("FacadeTestNote");

            // Send notification. The Command associated with the event
            // (FacadeTestCommand) will NOT be invoked, and will NOT multiply
            // the vo.input value by 2
            FacadeTestVO vo = new FacadeTestVO(32);

            facade.SendNotification("FacadeTestNote", vo);

            // test assertions
            Assert.True(vo.result != 64, "Expecting vo.result != 64");
        }
        /**
  		 * Tests Command registration and execution via the Facade.
  		 * 
  		 * <P>
  		 * This test gets the Singleton Facade instance 
  		 * and registers the FacadeTestCommand class 
  		 * to handle 'FacadeTest' Notifcations.<P>
  		 * 
  		 * <P>
  		 * It then constructs such a Notification and notifies Observers
  		 * via the Facade. Success is determined by evaluating 
  		 * a property on an object placed in the body of
  		 * the Notification, which will be modified by the Command.</P>
  		 * 
  		 */
  		public void TestRegisterCommandAndNotifyObservers()
        {
   			// Create the Facade, register the FacadeTestCommand to 
   			// handle 'FacadeTest' events
			IFacade facade = Facade.Instance;
   			facade.RegisterCommand("FacadeTestNote", typeof(FacadeTestCommand));

			// Send notification. The Command associated with the event
			// (FacadeTestCommand) will be invoked, and will multiply 
			// the vo.input value by 2 and set the result on vo.result
			FacadeTestVO vo = new FacadeTestVO(32);
            facade.SendNotification("FacadeTestNote", vo);
   			
   			// test assertions 
   			Assert.True(vo.result == 64, "Expecting vo.result == 64");
   		}
		public void RegisterAndRemoveCommandAndSendNotification()
        {
   			// Create the Facade, register the FacadeTestCommand to 
   			// handle 'FacadeTest' events
			IFacade facade = Facade.Instance;
   			facade.RegisterCommand("FacadeTestNote", typeof(FacadeTestCommand));
   			facade.RemoveCommand("FacadeTestNote");

			// Send notification. The Command associated with the event
			// (FacadeTestCommand) will NOT be invoked, and will NOT multiply 
			// the vo.input value by 2 
            FacadeTestVO vo = new FacadeTestVO(32);
   			facade.SendNotification("FacadeTestNote", vo);
   			
   			// test assertions 
   			Assert.IsTrue(vo.result != 64, "Expecting vo.result != 64");
   		}