Пример #1
0
        public void ProcessReceivedMessageInputValidMessageAssertValid()
        {
            var jsonDataContractSerializer = new JsonDataContractSerializer();

            var messageFake = new MessageFake { CreatedAt = DateTime.Now.Date };
            var messageBus = MessageBusFactory.Create(new Identification(), messageFake, jsonDataContractSerializer);

            var inputGateway = RouterGatewayFactory.CreateInputGateway(_receiverEndPoint.Object, 5);

            var eventargs = new EventReceiverEndPointHandlerArgs
            {
                Message = Encoding.UTF8.GetBytes(jsonDataContractSerializer.Serialize(messageBus))
            };

            _receiverEndPoint.Setup(r => r.Start()).Raises(r => r.OnReceivedMessage += null, new object[] { null, eventargs });

            MessageBus messageReceived = null;
            inputGateway.OnMessage += (sender, args) => messageReceived = jsonDataContractSerializer.Deserialize<MessageBus>(args.Message);

            inputGateway.Start();

            Assert.AreEqual(messageBus.Body, messageReceived.Body);
            Assert.AreEqual(messageBus.Header.Type, messageReceived.Header.Type);
            Assert.AreEqual(messageBus.Header.BodyType, messageReceived.Header.BodyType);
        }
Пример #2
0
        /// <summary>
        /// Invokes the on received message.
        /// </summary>
        /// <param name="args">The args.</param>
        private void InvokeOnReceivedMessage(EventReceiverEndPointHandlerArgs args)
        {
            EventReceiverEndPointHandler handler = OnReceivedMessage;

            if (handler != null)
            {
                handler(this, args);
            }
        }
Пример #3
0
        public void ProcessReceivedMessageInputValidMessageAssertValid()
        {
            var jsonDataContractSerializer = new JsonDataContractSerializer();

            var messageFake = new MessageFake { CreatedAt = DateTime.Now.Date };
            var messageBus = MessageBusFactory.Create(new Identification(), messageFake, jsonDataContractSerializer);

            var inputGateway = AgentGatewayFactory.CreateInputGateway<IMessage>(_receiverEndPoint.Object, 5);

            var eventargs = new EventReceiverEndPointHandlerArgs
                                {
                                    Message = Encoding.UTF8.GetBytes(jsonDataContractSerializer.Serialize(messageBus))
                                };

            _receiverEndPoint.Setup(r => r.Start()).Raises(r => r.OnReceivedMessage += null,
                                                            new object[] { null, eventargs });

            IMessage messageReceived = null;
            inputGateway.OnMessage += (sender, args) => messageReceived = args.Message;

            inputGateway.Start();

            Assert.AreEqual(messageFake.CreatedAt, ((IMessageFake)messageReceived).CreatedAt);
        }
Пример #4
0
 /// <summary>
 /// Messages the received.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The args.</param>
 private void OnReceiverChannelMessageReceived(object sender, EventReceiverEndPointHandlerArgs args)
 {
     Logger.Debug("End Point Receiver Message Started");
     InvokeOnReceivedMessage(args);
 }
Пример #5
0
 /// <summary>
 /// Invokes the on received message.
 /// </summary>
 /// <param name="args">The args.</param>
 private void InvokeOnReceivedMessage(EventReceiverEndPointHandlerArgs args)
 {
     EventReceiverEndPointHandler handler = OnReceivedMessage;
     if (handler != null) handler(this, args);
 }
Пример #6
0
 /// <summary>
 /// Messages the received.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The args.</param>
 private void OnReceiverChannelMessageReceived(object sender, EventReceiverEndPointHandlerArgs args)
 {
     Logger.Debug("End Point Receiver Message Started");
     InvokeOnReceivedMessage(args);
 }