Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSB.Testing: ExpectSend cannot handle Bus.Send(m1, m2, m3) #489

Closed
agross opened this issue Jun 20, 2012 · 2 comments
Closed

NSB.Testing: ExpectSend cannot handle Bus.Send(m1, m2, m3) #489

agross opened this issue Jun 20, 2012 · 2 comments
Assignees
Milestone

Comments

@agross
Copy link

agross commented Jun 20, 2012

I just tried NSB.Testing for the first time:

namespace Blah
{
  public class TheHandler : IHandleMessages<Incoming>
  {
    public IBus Bus { get; set; }

    public void Handle(Incoming message)
    {
      var one = Bus.CreateInstance<Ougoing>(m =>
      {
        m.Number = 1;
      });

      var two = Bus.CreateInstance<Ougoing>(m =>
      {
        m.Number = 2;
      });

      // Fails:
      Bus.Send(one, two);

      // Works:
      // Bus.Send(one);
      // Bus.Send(two);
    }
  }

  public class Ougoing
  {
    public int Number { get; set; }
  }

  public class Incoming
  {
  }

  public class When_an_incoming_message_is_received
  {
    It should_send_an_outgoing_message_with__one__ =
      () => Test
              .Handler<TheHandler>()
              .ExpectSend<Ougoing>(m => m.Number == 1)
              .OnMessage<Incoming>();

    It should_send_an_outgoing_message_with__two__ =
      () => Test
              .Handler<TheHandler>()
              .ExpectSend<Ougoing>(m => m.Number == 2)
              .OnMessage<Incoming>();
  }
}

It seems as if ExpectSend does not handle sending multiple messages as one transport message:

ExpectedSendInvocation<Blah.Outgoing> not fulfilled.
Calls made:
SendInvocation<Blah.Outgoing>
@yngvebn
Copy link

yngvebn commented Jun 21, 2012

The same issue applies to ExpectedPublishInvocation (ExpectPublish when using bus.Publish(params T[] messages) - ref: http://stackoverflow.com/questions/11118415/expectpublish-fails-when-publishparams-t-messages-contains-more-than-one-mes/11126469

@ghost ghost assigned johnsimons Jul 18, 2012
johnsimons pushed a commit that referenced this issue Jul 30, 2012
Conflicts:

	src/testing/NServiceBus.Testing.Tests/SagaTests.cs
	src/testing/NServiceBus.Testing.Tests/TestHandlerFixture.cs
	src/testing/NServiceBus.Testing.Tests/Timeouts.cs
@brunobertechini
Copy link

Hi,

Im using 4.7.1 and have a handler that uses a for loop and do several Bus.SendLocal inside. Im not using the obsolete Bus.SendLocal(object[] messages) api.

Im using

for(int i = 0; i < 5; i++)
{
Bus.SendLocal(cmd => { cmd.Id = id++; });
}

Bus the ExpectSendLocal is invoked only once. If I explicit more than one ExpectSendLocal directives, all instances are called with the first element.

Do I need to do anything different or is it a bug ?

Bruno Bertechini

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants