public void Establish() { _mapper = new HeartbeatReplyCommandMessageMapper(); _request = new HeartbeatReply("Test.Hostname", new ReplyAddress(TOPIC, _correlationId)); _firstConsumer = new RunningConsumer(new ConnectionName("Test.Connection"), ConsumerState.Open); _request.Consumers.Add(_firstConsumer); _secondConsumer = new RunningConsumer(new ConnectionName("More.Consumers"), ConsumerState.Shut); _request.Consumers.Add(_secondConsumer); }
/// <summary> /// We want to send a heartbeat back to the caller. The heartbeat consists of the set of channels we own /// and their current status. /// </summary> /// <param name="command">The command.</param> /// <returns>TRequest.</returns> public override HeartbeatRequest Handle(HeartbeatRequest command) { var heartbeat = new HeartbeatReply(_dispatcher.HostName, new ReplyAddress(command.ReplyAddress.Topic, command.ReplyAddress.CorrelationId)); _dispatcher.Consumers.Each((consumer) => heartbeat.Consumers.Add(new RunningConsumer(consumer.Name, consumer.State))); _commandProcessor.Post(heartbeat); return(base.Handle(command)); }
public HeartbeatReplyToMessageMapperTests() { _mapper = new HeartbeatReplyCommandMessageMapper(); _request = new HeartbeatReply("Test.Hostname", new ReplyAddress(TOPIC, _correlationId)); var firstConsumer = new RunningConsumer(new ConsumerName("Test.Consumer1"), ConsumerState.Open); _request.Consumers.Add(firstConsumer); var secondConsumer = new RunningConsumer(new ConsumerName("More.Consumers2"), ConsumerState.Shut); _request.Consumers.Add(secondConsumer); }
public void When_mapping_from_a_message_to_a_heartbeat_reply() { _request = _mapper.MapToRequest(_message); // _should_set_the_sender_address_topic _request.SendersAddress.Topic.Should().Be(TOPIC); // _should_set_the_sender_correlation_id _request.SendersAddress.CorrelationId.Should().Be(_correlationId); // _should_set_the_hostName _request.HostName.Should().Be("Test.Hostname"); // _should_contain_the_consumers _request.Consumers.Should().Contain(rc => rc.ConsumerName == "Test.Subscription" && rc.State == ConsumerState.Open); _request.Consumers.Should().Contain(rc => rc.ConsumerName == "More.Consumers" && rc.State == ConsumerState.Shut); }
public void When_mapping_from_a_message_to_a_heartbeat_reply() { _request = _mapper.MapToRequest(_message); // _should_set_the_sender_address_topic Assert.AreEqual(TOPIC, _request.SendersAddress.Topic); // _should_set_the_sender_correlation_id Assert.AreEqual(_correlationId, _request.SendersAddress.CorrelationId); // _should_set_the_hostName Assert.AreEqual("Test.Hostname", _request.HostName); // _should_contain_the_consumers Assert.True((bool)_request.Consumers.Any(rc => rc.ConnectionName == "Test.Connection" && rc.State == ConsumerState.Open)); Assert.True(_request.Consumers.Any(rc => rc.ConnectionName == "More.Consumers" && rc.State == ConsumerState.Shut)); }