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); }
public void SerializeSpanishLettersMessageBus() { var jsonDataContractSerializer = new JsonDataContractSerializer(); var messageBus = new MessageBus { Body = "El señor de l'ametlla del vallès está de vacaciones", Header = { BodyType = "System.string", CreatedAt = new DateTime(2010, 10, 10) } }; var serialize = jsonDataContractSerializer.Serialize(messageBus); var deserialized = jsonDataContractSerializer.Deserialize(serialize, Encoding.UTF8, typeof(MessageBus)) as MessageBus; Assert.AreEqual(messageBus.Body, deserialized.Body); Assert.AreEqual(messageBus.Header, deserialized.Header); }
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); }