public void should_release_task_when_completion_message_is_sent() { using (MessageId.PauseIdGeneration()) { var command = new FakeCommand(123); SetupPeersHandlingMessage<FakeCommand>(_peerUp); _bus.Start(); var task = _bus.Send(command); var commandCompleted = new MessageExecutionCompleted(MessageId.NextId(), 1, "Error message"); _transport.RaiseMessageReceived(commandCompleted.ToTransportMessage()); var receivedAck = task.Wait(10); receivedAck.ShouldBeTrue(); task.Result.ErrorCode.ShouldEqual(1); task.Result.ResponseMessage.ShouldEqual("Error message"); } }
public void should_not_continue_execution_after_awaiting_a_send_in_the_MessageReceived_thread() { using (MessageId.PauseIdGeneration()) { var command = new FakeCommand(456); SetupPeersHandlingMessage<FakeCommand>(_peerUp); _bus.Start(); var task = _bus.Send(command); var commandCompleted = new MessageExecutionCompleted(MessageId.NextId(), 0, null); int backgroundThreadId = 0; BackgroundThread.Start(() => { backgroundThreadId = Thread.CurrentThread.ManagedThreadId; _transport.RaiseMessageReceived(commandCompleted.ToTransportMessage()); }); var getThreadIdTask = GetThreadIfAfterAwaitingCommandResult(task); getThreadIdTask.Result.ShouldNotEqual(backgroundThreadId); } }