Пример #1
0
        /// <summary>
        /// Fabricate a result by multiplying the input by 2
        /// </summary>
        /// <param name="notification">note the Notification carrying the FacadeTestVO</param>
        public override void Execute(INotification notification)
        {
            FacadeTestVO vo = (FacadeTestVO)notification.Body;

            // Fabricate a result
            vo.result = 2 * vo.input;
        }
Пример #2
0
        public void TestRegisterCommandAndSendNotification()
        {
            // Create the Facade, register the FacadeTestCommand to
            // handle 'FacadeTest' notifications
            var facade = Facade.GetInstance("FacadeTestKey2", key => new Facade(key));

            facade.RegisterCommand("FacadeTestNote", () => new 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");
        }
Пример #3
0
        public void TestRegisterAndRemoveCommandAndSendNotification()
        {
            // Create the Facade, register the FacadeTestCommand to
            // handle 'FacadeTest' events
            IFacade facade = Facade.GetInstance(() => new Facade());

            facade.RegisterCommand("FacadeTestNote", () => new 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");
        }