コード例 #1
0
        public void FiresOnEventBroker()
        {
            IEventFired message = GetMessage();

            this.testee.TestDoHandle(message);

            A.CallTo(() => this.eventBroker.Fire("topic://Appccelerate.DistributedEventBroker/DISTRIBUTED", this.testee, HandlerRestriction.Asynchronous, this.testee, A <EventArgs <IEventFired> > .Ignored)).MustHaveHappened();
        }
コード例 #2
0
        /// <summary>
        /// Message handler which can be called by extensions or internal event brokers.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="eventFired">The event fired.</param>
        protected virtual void HandleMessage(object sender, IEventFired eventFired)
        {
            Ensure.ArgumentNotNull(eventFired, "eventFired");

            if (this.HostedEventBrokerIdentification.Equals(eventFired.EventBrokerIdentification))
            {
                return;
            }

            var eventArgsType = Type.GetType(eventFired.EventArgsType, true);

            var eventArgs = this.Serializer.Deserialize(eventArgsType, eventFired.EventArgs);

            this.HostedEventBroker.Fire(eventFired.Topic, this, eventFired.HandlerRestriction, this, eventArgs);
        }
コード例 #3
0
        /// <summary>
        /// Publishes the specified event fired message on the bus.
        /// </summary>
        /// <param name="message">The message.</param>
        public void Publish(IEventFired message)
        {
            var eventFired = message as INServiceBusEventFired;

            if (eventFired == null)
            {
                throw new ArgumentException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              "Type must be convertible to {0}!",
                              typeof(INServiceBusEventFired).Name),
                          "message");
            }

            this.serviceBus.Publish(eventFired);
        }
コード例 #4
0
        /// <summary>
        /// Publishes the specified event fired message on the bus.
        /// </summary>
        /// <param name="message">The message.</param>
        public void Publish(IEventFired message)
        {
            var eventFired = message as INServiceBusEventFired;

            if (eventFired == null)
            {
                throw new ArgumentException(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "Type must be convertible to {0}!",
                        typeof(INServiceBusEventFired).Name),
                    "message");
            }

            this.serviceBus.Publish(eventFired);
        }
コード例 #5
0
        public void PassesMessageToEventArgs()
        {
            EventArgs <IEventFired> collectedArgs = null;
            IEventFired             message       = GetMessage();

            A.CallTo(
                () =>
                this.eventBroker.Fire(
                    A <string> .Ignored,
                    A <object> .Ignored,
                    A <HandlerRestriction> .Ignored,
                    A <object> .Ignored,
                    A <EventArgs> .Ignored)).Invokes(fake => collectedArgs = fake.Arguments.Get <EventArgs <IEventFired> >(4));

            this.testee.TestDoHandle(message);

            collectedArgs.Should().NotBeNull();
            collectedArgs.Value.Should().BeSameAs(message);
        }
コード例 #6
0
 public void TestDoHandle(IEventFired message)
 {
     this.DoHandle(message);
 }
コード例 #7
0
        /// <summary>
        /// Creates the dynamic topic according to the message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>The topic uri.</returns>
        protected virtual string CreateTopic(IEventFired message)
        {
            Ensure.ArgumentNotNull(message, "message");

            return string.Format(CultureInfo.InvariantCulture, Constants.InternalTopicFormat, message.DistributedEventBrokerIdentification);
        }
コード例 #8
0
 public void Handle(IEventFired message)
 {
     this.fakeEventFiredHandler.Handle(message);
 }
コード例 #9
0
        /// <summary>
        /// Message handler which can be called by extensions or internal event brokers.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="eventFired">The event fired.</param>
        protected virtual void HandleMessage(object sender, IEventFired eventFired)
        {
            Ensure.ArgumentNotNull(eventFired, "eventFired");

            if (this.HostedEventBrokerIdentification.Equals(eventFired.EventBrokerIdentification))
            {
                return;
            }

            var eventArgsType = Type.GetType(eventFired.EventArgsType, true);

            var eventArgs = this.Serializer.Deserialize(eventArgsType, eventFired.EventArgs);

            this.HostedEventBroker.Fire(eventFired.Topic, this, eventFired.HandlerRestriction, this, eventArgs);
        }
 /// <summary>
 /// Publishes the specified event fired message on the bus.
 /// </summary>
 /// <param name="message">The message.</param>
 public void Publish(IEventFired message)
 {
     this.serviceBus.Publish(message);
 }
コード例 #11
0
        /// <summary>
        /// Fires the message event on the internal event broker.
        /// </summary>
        /// <param name="message">The message.</param>
        protected virtual void DoHandle(IEventFired message)
        {
            string topic = this.CreateTopic(message);

            this.EventBroker.Fire(topic, this, HandlerRestriction.Asynchronous, this, new EventArgs <IEventFired>(message));
        }
コード例 #12
0
 protected override void DoHandle(IEventFired message)
 {
     this.DoHandleWasCalled = true;
 }
コード例 #13
0
 public void TestDoHandle(IEventFired message)
 {
     this.DoHandle(message);
 }
コード例 #14
0
 public void Handle(IEventFired message)
 {
     this.fakeEventFiredHandler.Handle(message);
 }
コード例 #15
0
 public void Publish(IEventFired message)
 {
     this.eventFiredHandler.Handle(message);
 }
コード例 #16
0
 public void TestHandleMessage(IEventFired eventFired)
 {
     this.HandleMessage(this, eventFired);
 }
コード例 #17
0
 protected override void DoHandle(IEventFired message)
 {
     this.DoHandleWasCalled = true;
 }
コード例 #18
0
        /// <summary>
        /// Creates the dynamic topic according to the message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>The topic uri.</returns>
        protected virtual string CreateTopic(IEventFired message)
        {
            Ensure.ArgumentNotNull(message, "message");

            return(string.Format(CultureInfo.InvariantCulture, Constants.InternalTopicFormat, message.DistributedEventBrokerIdentification));
        }
コード例 #19
0
 public void TestHandleMessage(IEventFired eventFired)
 {
     this.HandleMessage(this, eventFired);
 }
コード例 #20
0
 /// <summary>
 /// Publishes the specified event fired message on the bus.
 /// </summary>
 /// <param name="message">The message.</param>
 public void Publish(IEventFired message)
 {
     this.serviceBus.Notify(message);
 }
コード例 #21
0
        /// <summary>
        /// Fires the message event on the internal event broker.
        /// </summary>
        /// <param name="message">The message.</param>
        protected virtual void DoHandle(IEventFired message)
        {
            string topic = this.CreateTopic(message);

            this.EventBroker.Fire(topic, this, this.Restriction, this, new EventArgs<IEventFired>(message));
        }
コード例 #22
0
 public void Publish(IEventFired message)
 {
     this.eventFiredHandler.Handle(message);
 }