protected internal void RaiseZplTemplateChanged()
 {
     if (EventRaiser != null)
     {
         EventRaiser.Raise(ref ZplTemplateChanged, ZplTemplateFile);
     }
 }
 protected internal void RaiseZebraIpChangedEvent()
 {
     if (EventRaiser != null)
     {
         EventRaiser.Raise(ref ZebraIpChanged, ZebraPrinterIP);
     }
 }
Exemple #3
0
        /// <summary>
        /// Provides the ability to raise an event that has had an expectation created
        /// </summary>
        /// <typeparam name="T">the mocked type</typeparam>
        /// <param name="instance">the mocked instance</param>
        /// <param name="eventSubscription">the event that has had an expectation created</param>
        /// <param name="args">arguments used to the raise event</param>
        /// <returns>collection of the actual calls</returns>
        /// <exception cref="System.ArgumentNullException">thrown when the instance is null</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// thrown when the instance cannot be identified as a mocked object or the given method is not an event
        /// </exception>
        public static void Raise <T>(this T instance, Action <T> eventSubscription, object[] args)
            where T : class
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance", "Events cannot be raised from a null object or instance.");
            }

            var container = GetExpectationContainer(instance);

            if (container == null)
            {
                throw new ArgumentOutOfRangeException("instance", "Events can only be raised from a mocked object or instance.");
            }

            var expectation = new ExpectEvent();

            container.MarkForAssertion(expectation);

            try
            {
                eventSubscription(instance);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Exception caught while identifying event", ex);
            }

            if (container.ExpectationMarked)
            {
                throw new InvalidOperationException();
            }

            var method = expectation.Method;

            if (!method.IsSpecialName)
            {
                throw new InvalidOperationException("Raise method can only be used against events.");
            }

            var methodName = method.Name;

            if (!methodName.StartsWith("add_"))
            {
                throw new InvalidOperationException("Raise method can only be used against events.");
            }

            var eventName    = methodName.Substring(4);
            var subscription = container.GetEventSubscribers(eventName);

            if (subscription == null)
            {
                return;
            }

            var raiser = new EventRaiser(instance);

            raiser.Raise(subscription, args);
        }
    public void WriteAll()
    {
        int b;

        while ((b = _source.ReadByte()) != -1)
        {
            _destination.WriteByte((byte)b);
            EventRaiser.Raise(ProgressChanged, this);     // Just one call here! Can't be less
        }
    }
Exemple #5
0
        /// <summary>
        /// Raises the metrics changed event.
        /// </summary>
        /// <param name="oee">A value between 0 and 1 indicating the speedometer (for whatever metric).</param>
        protected internal void RaiseMetricsChangedEvent()
        {
            // callbacks will be raised in any case even if the state hasn't changed. to update WCF clients.
            if (EventRaiser != null)
            {
                var metrics = new MetricsDTO(
                    OverallItemCount,
                    Metrics.UpTime,
                    Metrics.DownTime,
                    Metrics.OverallEquipmentEfficiency);

                EventRaiser.Raise(ref MetricsChangedCallback, metrics);
            }
        }
        public void TriggerAndVerifyRespondingToEvents()
        {
            MockRepository mocks       = new MockRepository();
            IView          viewStub    = mocks.Stub <IView>();
            IWebService    serviceMock = mocks.CreateMock <IWebService>();

            using (mocks.Record())
            {
                serviceMock.LogInfo("view loaded");
            }
            new Presenter(viewStub, serviceMock);
            IEventRaiser eventer = new EventRaiser((IMockedObject)viewStub, "Load");

            eventer.Raise(null, EventArgs.Empty);

            mocks.VerifyAll();
        }
Exemple #7
0
        internal protected void RaiseModuleStateChangedEvent()
        {
            // callbacks will be raised in any case even if the state hasn't changed. to update WCF clients.
            if (EventRaiser != null)
            {
                EventRaiser.Raise(ref ModuleStateChangedCallback, this.ToDTO());
            }

            if (State != _oldModuleState)
            {
                var handle = ModuleStateChangedEvent;
                if (handle != null)
                {
                    handle(this, State);
                }
                _oldModuleState = State;
            }
        }
Exemple #8
0
 public void TriggerCallbackEvent()
 {
     EventRaiser.Raise(ref AlarmsChanged, _moduleName);
 }
Exemple #9
0
 public void RaiseEvent(string eventName)
 {
     EventRaiser.Raise(eventName);
 }