public void FromMessageWithNonMatchingMessageType()
        {
            var translator = new EndpointDisconnectConverter();

            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 FromMessage()
        {
            var translator = new EndpointDisconnectConverter();

            var msg  = new EndpointDisconnectMessage(new EndpointId("a"), "b");
            var data = translator.FromMessage(msg);

            Assert.IsInstanceOf(typeof(EndpointDisconnectData), data);
            Assert.AreSame(msg.Id, data.Id);
            Assert.AreSame(msg.Sender, data.Sender);
            Assert.AreSame(msg.InResponseTo, data.InResponseTo);
            Assert.AreSame(msg.ClosingReason, ((EndpointDisconnectData)data).DisconnectReason);
        }
        public void ToMessageWithNonMatchingDataType()
        {
            var translator = new EndpointDisconnectConverter();

            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 ToMessage()
        {
            var translator = new EndpointDisconnectConverter();

            var data = new EndpointDisconnectData
            {
                Id               = new MessageId(),
                InResponseTo     = new MessageId(),
                Sender           = new EndpointId("a"),
                DisconnectReason = "b",
            };
            var msg = translator.ToMessage(data);

            Assert.IsInstanceOf(typeof(EndpointDisconnectMessage), msg);
            Assert.AreSame(data.Id, msg.Id);
            Assert.AreSame(data.Sender, msg.Sender);
            Assert.AreSame(data.DisconnectReason, ((EndpointDisconnectMessage)msg).ClosingReason);
        }
        public void DataTypeToTranslate()
        {
            var translator = new EndpointDisconnectConverter();

            Assert.AreEqual(typeof(EndpointDisconnectData), translator.DataTypeToTranslate);
        }
        public void MessageTypeToTranslate()
        {
            var translator = new EndpointDisconnectConverter();

            Assert.AreEqual(typeof(EndpointDisconnectMessage), translator.MessageTypeToTranslate);
        }