public void When_mapping_from_a_heartbeat_request_to_a_message()
        {
            _message = _mapper.MapToMessage(_request);

            //_should_serialize_the_message_type_to_the_header
            Assert.AreEqual(MessageType.MT_COMMAND, _message.Header.MessageType);
            //_should_serialize_the_message_id_to_the_message_body
            Assert.True(_message.Body.Value.Contains(string.Format("\"Id\": \"{0}\"", _request.Id)));
            //_should_serialize_the_topic_to_the_message_body
            Assert.AreEqual(TOPIC, _message.Header.ReplyTo);
            //_should_serialize_the_correlation_id_to_the_message_body
            Assert.AreEqual(_correlationId, _message.Header.CorrelationId);
        }
Exemplo n.º 2
0
        public void When_mapping_to_a_wire_message_from_a_configuration_command()
        {
            _message = _mapper.MapToMessage(_command);

            // _should_serialize_the_command_type_to_the_message_body
            Assert.True(_message.Body.Value.Contains("\"Type\":1"));
            //_should_serialize_the_message_type_to_the_header
            Assert.AreEqual(MessageType.MT_COMMAND, _message.Header.MessageType);
            //_should_serialize_the_connection_name_to_the_message_body
            Assert.True(_message.Body.Value.Contains("\"ConnectionName\":\"getallthethings\""));
            //_should_serialize_the_message_id_to_the_message_body
            Assert.True(_message.Body.Value.Contains(string.Format("\"Id\":\"{0}\"", _command.Id)));
        }
Exemplo n.º 3
0
        public void When_mapping_to_a_wire_message_from_a_configuration_command()
        {
            _message = _mapper.MapToMessage(_command);

            // _should_serialize_the_command_type_to_the_message_body
            _message.Body.Value.Should().Contain("\"Type\":1");
            //_should_serialize_the_message_type_to_the_header
            _message.Header.MessageType.Should().Be(MessageType.MT_COMMAND);
            //_should_serialize_the_connection_name_to_the_message_body
            _message.Body.Value.Should().Contain("\"ConnectionName\":\"getallthethings\"");
            //_should_serialize_the_message_id_to_the_message_body
            _message.Body.Value.Should().Contain($"\"Id\":\"{_command.Id}\"");
        }
        public void When_mapping_from_a_heartbeat_request_to_a_message()
        {
            _message = _mapper.MapToMessage(_request);

            //_should_serialize_the_message_type_to_the_header
            _message.Header.MessageType.Should().Be(MessageType.MT_COMMAND);
            //_should_serialize_the_message_id_to_the_message_body
            _message.Body.Value.Should().Contain($"\"Id\": \"{_request.Id}\"");
            //_should_serialize_the_topic_to_the_message_body
            _message.Header.ReplyTo.Should().Be(TOPIC);
            //_should_serialize_the_correlation_id_to_the_message_body
            _message.Header.CorrelationId.Should().Be(_correlationId);
        }
        public void When_mapping_from_a_heartbeat_reply_to_a_message()
        {
            _message = _mapper.MapToMessage(_request);

            //_should_put_the_reply_to_as_the_topic
            Assert.AreEqual(TOPIC, _message.Header.Topic);
            //_should_put_the_correlation_id_in_the_header
            Assert.AreEqual(_correlationId, _message.Header.CorrelationId);
            //_should_put_the_connections_into_the_body
            Assert.True(((Func <MessageBody, bool>)(body => body.Value.Contains("\"ConnectionName\": \"Test.Connection\""))).Invoke(_message.Body));
            Assert.True(((Func <MessageBody, bool>)(body => body.Value.Contains("\"State\": 1"))).Invoke(_message.Body));
            Assert.True(((Func <MessageBody, bool>)(body => body.Value.Contains("\"ConnectionName\": \"More.Consumers\""))).Invoke(_message.Body));
            Assert.True(((Func <MessageBody, bool>)(body => body.Value.Contains("\"State\": 0"))).Invoke(_message.Body));
            //_should_put_the_hostname_in_the_message_body
            Assert.True(((Func <MessageBody, bool>)(body => body.Value.Contains("\"HostName\": \"Test.Hostname\""))).Invoke(_message.Body));
        }
Exemplo n.º 6
0
        public void When_mapping_from_a_heartbeat_reply_to_a_message()
        {
            _message = _mapper.MapToMessage(_request);

            //_should_put_the_reply_to_as_the_topic
            _message.Header.Topic.Should().Be(TOPIC);
            //_should_put_the_correlation_id_in_the_header
            _message.Header.CorrelationId.Should().Be(_correlationId);
            //_should_put_the_connections_into_the_body
            _message.Body.Value.Should().Contain("\"consumerName\":\"Test.Consumer1\"");
            _message.Body.Value.Should().Contain("\"state\":1");
            _message.Body.Value.Should().Contain("\"consumerName\":\"More.Consumers2\"");
            _message.Body.Value.Should().Contain("\"state\":0");

            //_should_put_the_hostname_in_the_message_body
            _message.Body.Value.Should().Contain("\"hostName\":\"Test.Hostname\"");
        }