public void ToMessage() { var translator = new EndpointConnectConverter(); var data = new EndpointConnectData { Id = new MessageId(), InResponseTo = new MessageId(), Sender = new EndpointId("a"), DiscoveryAddress = new Uri("http://localhost/discovery/invalid"), ProtocolVersion = new Version(1, 0), MessageAddress = new Uri("http://localhost/protocol/message/invalid"), DataAddress = new Uri("http://localhost/protocol/data/invalid"), Information = new ProtocolDescription( new[] { new CommunicationSubject("b"), }), }; var msg = translator.ToMessage(data); Assert.IsInstanceOf(typeof(EndpointConnectMessage), msg); Assert.AreSame(data.Id, msg.Id); Assert.AreSame(data.Sender, msg.Sender); Assert.AreSame(data.DiscoveryAddress, ((EndpointConnectMessage)msg).DiscoveryInformation.Address); Assert.AreSame(data.ProtocolVersion, ((EndpointConnectMessage)msg).ProtocolInformation.Version); Assert.AreSame(data.MessageAddress, ((EndpointConnectMessage)msg).ProtocolInformation.MessageAddress); Assert.AreSame(data.DataAddress, ((EndpointConnectMessage)msg).ProtocolInformation.DataAddress); Assert.AreSame(data.Information, ((EndpointConnectMessage)msg).Information); }
public void FromMessage() { var translator = new EndpointConnectConverter(); var msg = new EndpointConnectMessage( new EndpointId("a"), new DiscoveryInformation(new Uri("http://localhost/discovery/invalid")), new ProtocolInformation( new Version(1, 0), new Uri("http://localhost/protocol/invalid")), new ProtocolDescription( new[] { new CommunicationSubject("b"), })); var data = translator.FromMessage(msg); Assert.IsInstanceOf(typeof(EndpointConnectData), data); Assert.AreSame(msg.Id, data.Id); Assert.AreSame(msg.Sender, data.Sender); Assert.AreSame(msg.InResponseTo, data.InResponseTo); Assert.AreSame(msg.DiscoveryInformation.Address, ((EndpointConnectData)data).DiscoveryAddress); Assert.AreSame(msg.ProtocolInformation.Version, ((EndpointConnectData)data).ProtocolVersion); Assert.AreSame(msg.ProtocolInformation.MessageAddress, ((EndpointConnectData)data).MessageAddress); Assert.AreSame(msg.ProtocolInformation.DataAddress, ((EndpointConnectData)data).DataAddress); Assert.AreSame(msg.Information, ((EndpointConnectData)data).Information); }
public void FromMessageWithNonMatchingMessageType() { var translator = new EndpointConnectConverter(); var msg = new SuccessMessage(new EndpointId("a"), new MessageId()); var data = translator.FromMessage(msg); Assert.IsInstanceOf(typeof(UnknownMessageTypeData), data); Assert.AreSame(msg.Id, data.Id); Assert.AreSame(msg.Sender, data.Sender); Assert.AreSame(msg.InResponseTo, data.InResponseTo); }
public void ToMessageWithNonMatchingDataType() { var translator = new EndpointConnectConverter(); var data = new SuccessData { Id = new MessageId(), InResponseTo = new MessageId(), Sender = new EndpointId("a"), }; var msg = translator.ToMessage(data); Assert.IsInstanceOf(typeof(UnknownMessageTypeMessage), msg); Assert.AreSame(data.Id, msg.Id); Assert.AreSame(data.Sender, msg.Sender); Assert.AreSame(data.InResponseTo, msg.InResponseTo); }
public void DataTypeToTranslate() { var translator = new EndpointConnectConverter(); Assert.AreEqual(typeof(EndpointConnectData), translator.DataTypeToTranslate); }
public void MessageTypeToTranslate() { var translator = new EndpointConnectConverter(); Assert.AreEqual(typeof(EndpointConnectMessage), translator.MessageTypeToTranslate); }