Ejemplo n.º 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 = 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the output.
        /// </summary>
        /// <returns></returns>
        private PublisherConfigurator CreateOutput()
        {
            var uri = new Uri(_publisherConfig.Output.Uri);

            _output = AgentGatewayFactory.CreateOutputGateway(_identification, uri, _publisherConfig.Output.Transport);
            return(this);
        }
        /// <summary>
        /// Outputs the specified bus config.
        /// </summary>
        /// <returns></returns>
        private ControlProcessorConfigurator CreateOutput()
        {
            var uri = new Uri(_HermEsbServiceConfig.Bus.ControlInput.Uri);

            _output = AgentGatewayFactory.CreateOutputGateway(_identification, uri, _HermEsbServiceConfig.Bus.ControlInput.Transport);
            return(this);
        }
        /// <summary>
        /// Creates the output.
        /// </summary>
        /// <returns></returns>
        private ErrorHandlingControllerConfigurator CreateOutput()
        {
            var uri = new Uri(_errorHandlingControllerConfig.Output.Uri);

            _output = AgentGatewayFactory.CreateOutputGateway(_identification, uri, _errorHandlingControllerConfig.Output.Transport);
            return(this);
        }
Ejemplo n.º 5
0
        public void CreateInputGatewayFromUriAndTransportTypeMsmqAndIDataContractSerializer()
        {
            var aig = AgentGatewayFactory.CreateInputGateway <IMessage>(_uri, _transportType, _fakeDataContractSerializer.Object, 100, 5);

            Assert.IsInstanceOf(typeof(AgentInputGateway <IMessage>), aig);
            Assert.AreEqual(aig.ReceiverEndPoint.Uri, _uri);
            Assert.AreEqual(aig.ReceiverEndPoint.Transport, _transportType);
        }
Ejemplo n.º 6
0
        public void CreateInputGatewayFromReceiverEndPoint()
        {
            var aig = AgentGatewayFactory.CreateInputGateway <IMessage>(_fakeIReceiverEndPoint.Object, 5);

            Assert.IsInstanceOf(typeof(AgentInputGateway <IMessage>), aig);
            Assert.AreEqual(aig.ReceiverEndPoint.Uri, _fakeIReceiverEndPoint.Object.Uri);
            Assert.AreEqual(aig.ReceiverEndPoint.Transport, _fakeIReceiverEndPoint.Object.Transport);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates the input.
        /// </summary>
        /// <returns></returns>
        private ListenerConfigurator CreateInput()
        {
            var uri = new Uri(_listenerConfig.Input.Uri);

            _input = AgentGatewayFactory.CreateInputGateway <IMessage>(uri, _listenerConfig.Input.Transport,
                                                                       _listenerConfig.NumberOfParallelTasks,
                                                                       _listenerConfig.MaxReijections);
            return(this);
        }
Ejemplo n.º 8
0
        public void CreateOutputGatewayFromIIdentificationAndUriAndTransportTypeMsmq()
        {
            var aog = AgentGatewayFactory.CreateOutputGateway(_fakeIdentification.Object, _uri, _transportType);

            Assert.IsInstanceOf(typeof(AgentOutputGateway), aog);
            Assert.AreEqual(aog.GetIdentification(), _fakeIdentification.Object);
            Assert.AreEqual(aog.GetSenderEndPoint().Uri, _uri);
            Assert.AreEqual(aog.GetSenderEndPoint().Transport, _transportType);
        }
Ejemplo n.º 9
0
        public void CreateOutputGatewayFromIIdentificationAndISenderEndPointAndIDataContractSerializer()
        {
            var aog = AgentGatewayFactory.CreateOutputGateway(_fakeIdentification.Object, _fakeISenderEndPoint.Object, _fakeDataContractSerializer.Object);

            Assert.IsInstanceOf(typeof(AgentOutputGateway), aog);
            Assert.AreEqual(aog.GetIdentification(), _fakeIdentification.Object);
            Assert.AreEqual(aog.GetSenderEndPoint().Uri, _fakeISenderEndPoint.Object.Uri);
            Assert.AreEqual(aog.GetSenderEndPoint().Transport, _fakeISenderEndPoint.Object.Transport);
        }
        /// <summary>
        /// Inputs the specified control processor config.
        /// </summary>
        /// <returns></returns>
        private ControlProcessorConfigurator CreateInput()
        {
            var uri = new Uri(_HermEsbServiceConfig.ControlProcessor.Input.Uri);

            _input = AgentGatewayFactory.CreateInputGateway <IControlMessage>(uri,
                                                                              _HermEsbServiceConfig.ControlProcessor.Input.Transport,
                                                                              _HermEsbServiceConfig.ControlProcessor.NumberOfParallelTasks,
                                                                              _HermEsbServiceConfig.ControlProcessor.MaxReijections);
            return(this);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Handles the message.
        /// </summary>
        /// <param name="message">The message.</param>
        public void HandleMessage(ISubscriptionCompletedMessage message)
        {
            Processor.JoinedBusInfo.Identification = message.BusIdentification;

            if (Processor is IConfigurableProcessor)
            {
                var outputGateway = AgentGatewayFactory.CreateOutputGateway(Processor.Identification,
                                                                            new Uri(message.InputGateway.Uri),
                                                                            message.InputGateway.Type);
                //TODO: Hacer el dispose del gateway viejoñ
                (Processor as IConfigurableProcessor).ConfigureOutputGateway(outputGateway);
                Processor.Start();
            }
        }
        /// <summary>
        /// Toes the subscriptor.
        /// </summary>
        /// <param name="subscriptorEntity">The subscriptor entity.</param>
        /// <param name="processor">The processor.</param>
        /// <returns></returns>
        public static Subscriptor ToSubscriptor(this SubscriptorEntity subscriptorEntity, Identification processor)
        {
            var subscriptor = new Subscriptor
            {
                Service             = subscriptorEntity.Service,
                ServiceInputGateway =
                    RouterGatewayFactory.CreateOutputGateway(
                        new Uri(subscriptorEntity.InputGateway.Uri),
                        (TransportType)subscriptorEntity.InputGateway.Transport),
                ServiceInputControlGateway =
                    AgentGatewayFactory.CreateOutputGateway(processor,
                                                            new Uri(subscriptorEntity.InputControlGateway.Uri),
                                                            (TransportType)subscriptorEntity.InputControlGateway.Transport),
            };


            foreach (var subscriptionTypeMessage in subscriptorEntity.SubcriptionTypes)
            {
                subscriptor.SubcriptionTypes.Add(subscriptionTypeMessage.ToSubscriptorKey());
            }
            return(subscriptor);
        }
Ejemplo n.º 13
0
        public void SendMessageAssertTrue()
        {
            var jsonDataContractSerializer = new JsonDataContractSerializer();

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

            var message = string.Empty;

            _senderEndPoint.Setup(s => s.Send(It.IsAny <string>(), It.IsAny <int>())).Callback <string, int>((s, p) => message = s);

            var outputGateway = AgentGatewayFactory.CreateOutputGateway(_identification, _senderEndPoint.Object);

            outputGateway.Send(messageFake);

            var deserialized = jsonDataContractSerializer.Deserialize <MessageBus>(message);

            Assert.AreEqual(messageBus.Body, deserialized.Body);
            Assert.AreEqual(messageBus.Header.Type, deserialized.Header.Type);
            Assert.AreEqual(messageBus.Header.BodyType, deserialized.Header.BodyType);
        }