Ejemplo n.º 1
0
        public void AssertThat_HandlerWasCalledOnce_DifferentEvent_OneCall()
        {
            //Because this combination of command and event type leads to the same event handler, the event handler is only handled once
            int expectedChanged   = 10;
            int expectedUnchanged = 0;

            var        Conf       = new Configuration();
            var        va         = Helpers.InitializeTestVA(Conf);
            Dispatcher dispatcher = va.EventDispatcher;

            var Env_BeforeCheckout       = va.CreateEventHandlerEnvironment(MFilesAPI.MFEventHandlerType.MFEventHandlerBeforeCheckOut);
            var command_3_BeforeCheckOut = new CustomCommand_3(Env_BeforeCheckout)
            {
                AddValue = 10
            };

            var Env_AfterCheckOut = va.CreateEventHandlerEnvironment(MFilesAPI.MFEventHandlerType.MFEventHandlerAfterCheckOut);

            Env_AfterCheckOut.CurrentUserID = Env_BeforeCheckout.CurrentUserID;

            var command_3_AfterCheckOut = new CustomCommand_3(Env_AfterCheckOut)
            {
                AddValue = 5
            };

            dispatcher.Dispatch(command_3_BeforeCheckOut, command_3_AfterCheckOut);

            Assert.AreEqual(expectedChanged, Env_BeforeCheckout.CurrentUserID);
            Assert.AreEqual(expectedUnchanged, Env_AfterCheckOut.CurrentUserID);
        }
Ejemplo n.º 2
0
        public void AssertThat_HandlerWasCalledTwice_DifferentEvent_TwoCalls()
        {
            //The same handler can be called from two different events
            int expected = 15;

            var        Conf       = new Configuration();
            var        va         = Helpers.InitializeTestVA(Conf);
            Dispatcher dispatcher = va.EventDispatcher;

            var Env_BeforeCheckout = va.CreateEventHandlerEnvironment(MFilesAPI.MFEventHandlerType.MFEventHandlerBeforeCheckOut);

            var command_3_BeforeCheckOut = new CustomCommand_3(Env_BeforeCheckout)
            {
                AddValue = 10
            };

            dispatcher.Dispatch(command_3_BeforeCheckOut);

            //Execute the same call with a different EventType
            var Env_AfterCheckOut = va.CreateEventHandlerEnvironment(MFilesAPI.MFEventHandlerType.MFEventHandlerAfterCheckOut);

            Env_AfterCheckOut.CurrentUserID = Env_BeforeCheckout.CurrentUserID;

            var command_3_AfterCheckOut = new CustomCommand_3(Env_AfterCheckOut)
            {
                AddValue = 5
            };

            dispatcher.Dispatch(command_3_AfterCheckOut);

            Assert.AreEqual(expected, Env_AfterCheckOut.CurrentUserID);
        }