Пример #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>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 public bool Equals(MessageFake other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other.CreatedAt.Equals(CreatedAt));
 }
Пример #3
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 = RouterGatewayFactory.CreateOutputGateway(_senderEndPoint.Object);
            var serialize = jsonDataContractSerializer.Serialize(messageBus);
            outputGateway.Send(Encoding.UTF8.GetBytes(serialize));
            Assert.AreEqual(serialize, message);
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
0
 /// <summary>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 public bool Equals(MessageFake other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.CreatedAt.Equals(CreatedAt);
 }