Testing a MassTransit Consumer using the InMemoryTestFixture The Next CEO of Stack OverflowHow should I unit test threaded code?How do I test a private function or a class that has private methods, fields or inner classes?Unit Testing C CodeIs Unit Testing worth the effort?JavaScript unit test tools for TDDWhat is Unit test, Integration Test, Smoke test, Regression Test?Running unittest with typical test directory structureNUnit test under monoHow to cancel long running task in MassTransitMassTransit 4 Unit Test Consumer timeout

If/When UK leaves the EU, can a future goverment conduct a referendum to join the EU?

Preparing Indesign booklet with .psd graphics for print

Inappropriate reference requests from Journal reviewers

Make solar eclipses exceedingly rare, but still have new moons

Why do professional authors make "consistency" mistakes? And how to avoid them?

Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?

Is it ever safe to open a suspicious html file (e.g. email attachment)?

Return the Closest Prime Number

In excess I'm lethal

Contours of a clandestine nature

What is the purpose of the Evocation wizard's Potent Cantrip feature?

Would a completely good Muggle be able to use a wand?

How do I transpose the first and deepest levels of an arbitrarily nested array?

Rotate a column

Is micro rebar a better way to reinforce concrete than rebar?

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Would a galaxy be visible from outside, but nearby?

Can you replace a racial trait cantrip when leveling up?

How did the Bene Gesserit know how to make a Kwisatz Haderach?

Is "for causing autism in X" grammatical?

Can we say or write : "No, it'sn't"?

Are there any limitations on attacking while grappling?

Why do we use the plural of movies in this phrase "We went to the movies last night."?

How to count occurrences of text in a file?



Testing a MassTransit Consumer using the InMemoryTestFixture



The Next CEO of Stack OverflowHow should I unit test threaded code?How do I test a private function or a class that has private methods, fields or inner classes?Unit Testing C CodeIs Unit Testing worth the effort?JavaScript unit test tools for TDDWhat is Unit test, Integration Test, Smoke test, Regression Test?Running unittest with typical test directory structureNUnit test under monoHow to cancel long running task in MassTransitMassTransit 4 Unit Test Consumer timeout










2















Wanting to design my test around a MassTransit Consumer where i can send the consumers messages with a variety of content. Base on the content of the message the consumer will "do work" and relay a messages.



The problem i have is when running two of these test, in separate test fixtures, there seems to be something interfering with the second test. But run individually each test runs successfully.



After looking through the MassTransit Test project i have come up with some example test code to demonstrate the problem i'm having.



 [TestFixture]
public class PingPongMessageTestFixture : InMemoryTestFixture

private PongConsumer _pongConsumer;
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator)

_received = Handled<IPongMessage>(configurator);


protected override void PreCreateBus(IInMemoryBusFactoryConfigurator configurator)

var _pingConsumer = new PingConsumer();
_pongConsumer = new PongConsumer();
configurator.ReceiveEndpoint("test_ping_queue", e =>

e.Consumer(() => _pingConsumer);
);

configurator.ReceiveEndpoint("test_pong_queue", e =>

e.Consumer(() => _pongConsumer);
);


Task<ConsumeContext<IPongMessage>> _received;

[Test]
public async Task test_how_to_test_consumers()

await Bus.Publish<IPingMessage>(new MessageId = 100 );
await _received;

Assert.IsTrue(_pongConsumer.hitme);
Assert.AreEqual(100, _pongConsumer.pongMessage.MessageId);


public class PingConsumer : IConsumer<IPingMessage>

public Task Consume(ConsumeContext<IPingMessage> context)

context.Publish<IPongMessage>(new context.Message.MessageId );
return Task.CompletedTask;



public class PongConsumer : IConsumer<IPongMessage>

internal bool hitme;
internal IPongMessage pongMessage;
public Task Consume(ConsumeContext<IPongMessage> context)

hitme = true;
pongMessage = context.Message;
return Task.CompletedTask;



public interface IPingMessage

int MessageId get; set;


public interface IPongMessage

int MessageId get; set;




this test will send a message to the ping consumer which itself will send a message to the pong consumer.



This by itself works and tests that the ping consumer will send a pong message. In a real life scenario the "ping" consumer to send Update messages to another service and the pong consumer is just a test consumer used with the tests.



If i have a second test fixture, which for this questions is very similar, it will fail when both test are run together. though individually it will pass.



The test does the same thing



[TestFixture]
public class DingDongMessageTestFixture : InMemoryTestFixture

private DongConsumer _pongConsumer;
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator)

_received = Handled<IDongMessage>(configurator);


protected override void PreCreateBus(IInMemoryBusFactoryConfigurator configurator)

var _dingConsumer = new DingConsumer();
_dongConsumer = new DongConsumer();
configurator.ReceiveEndpoint("test_ding_queue", e =>

e.Consumer(() => _dingConsumer);
);

configurator.ReceiveEndpoint("test_dong_queue", e =>

e.Consumer(() => _dongConsumer);
);


Task<ConsumeContext<IDongMessage>> _received;

[Test]
public async Task test_how_to_test_consumers()

await Bus.Publish<IDingMessage>(new MessageId = 100 );
await _received;

Assert.IsTrue(_pongConsumer.hitme);
Assert.AreEqual(100, _pongConsumer.pongMessage.MessageId);


public class DingConsumer : IConsumer<IDingMessage>

public Task Consume(ConsumeContext<IDingMessage> context)

context.Publish<IDongMessage>(new context.Message.MessageId );
return Task.CompletedTask;



public class DongConsumer : IConsumer<IDongMessage>

internal bool hitme;
internal IDongMessage pongMessage;
public Task Consume(ConsumeContext<IDongMessage> context)

hitme = true;
pongMessage = context.Message;
return Task.CompletedTask;



public interface IDingMessage

int MessageId get; set;


public interface IDongMessage

int MessageId get; set;




Is this a good approach for testing a Masstransit consumers?



If so, do i need to reset the InMemoryTestFixture, somehow, per test fixture?










share|improve this question




























    2















    Wanting to design my test around a MassTransit Consumer where i can send the consumers messages with a variety of content. Base on the content of the message the consumer will "do work" and relay a messages.



    The problem i have is when running two of these test, in separate test fixtures, there seems to be something interfering with the second test. But run individually each test runs successfully.



    After looking through the MassTransit Test project i have come up with some example test code to demonstrate the problem i'm having.



     [TestFixture]
    public class PingPongMessageTestFixture : InMemoryTestFixture

    private PongConsumer _pongConsumer;
    protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator)

    _received = Handled<IPongMessage>(configurator);


    protected override void PreCreateBus(IInMemoryBusFactoryConfigurator configurator)

    var _pingConsumer = new PingConsumer();
    _pongConsumer = new PongConsumer();
    configurator.ReceiveEndpoint("test_ping_queue", e =>

    e.Consumer(() => _pingConsumer);
    );

    configurator.ReceiveEndpoint("test_pong_queue", e =>

    e.Consumer(() => _pongConsumer);
    );


    Task<ConsumeContext<IPongMessage>> _received;

    [Test]
    public async Task test_how_to_test_consumers()

    await Bus.Publish<IPingMessage>(new MessageId = 100 );
    await _received;

    Assert.IsTrue(_pongConsumer.hitme);
    Assert.AreEqual(100, _pongConsumer.pongMessage.MessageId);


    public class PingConsumer : IConsumer<IPingMessage>

    public Task Consume(ConsumeContext<IPingMessage> context)

    context.Publish<IPongMessage>(new context.Message.MessageId );
    return Task.CompletedTask;



    public class PongConsumer : IConsumer<IPongMessage>

    internal bool hitme;
    internal IPongMessage pongMessage;
    public Task Consume(ConsumeContext<IPongMessage> context)

    hitme = true;
    pongMessage = context.Message;
    return Task.CompletedTask;



    public interface IPingMessage

    int MessageId get; set;


    public interface IPongMessage

    int MessageId get; set;




    this test will send a message to the ping consumer which itself will send a message to the pong consumer.



    This by itself works and tests that the ping consumer will send a pong message. In a real life scenario the "ping" consumer to send Update messages to another service and the pong consumer is just a test consumer used with the tests.



    If i have a second test fixture, which for this questions is very similar, it will fail when both test are run together. though individually it will pass.



    The test does the same thing



    [TestFixture]
    public class DingDongMessageTestFixture : InMemoryTestFixture

    private DongConsumer _pongConsumer;
    protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator)

    _received = Handled<IDongMessage>(configurator);


    protected override void PreCreateBus(IInMemoryBusFactoryConfigurator configurator)

    var _dingConsumer = new DingConsumer();
    _dongConsumer = new DongConsumer();
    configurator.ReceiveEndpoint("test_ding_queue", e =>

    e.Consumer(() => _dingConsumer);
    );

    configurator.ReceiveEndpoint("test_dong_queue", e =>

    e.Consumer(() => _dongConsumer);
    );


    Task<ConsumeContext<IDongMessage>> _received;

    [Test]
    public async Task test_how_to_test_consumers()

    await Bus.Publish<IDingMessage>(new MessageId = 100 );
    await _received;

    Assert.IsTrue(_pongConsumer.hitme);
    Assert.AreEqual(100, _pongConsumer.pongMessage.MessageId);


    public class DingConsumer : IConsumer<IDingMessage>

    public Task Consume(ConsumeContext<IDingMessage> context)

    context.Publish<IDongMessage>(new context.Message.MessageId );
    return Task.CompletedTask;



    public class DongConsumer : IConsumer<IDongMessage>

    internal bool hitme;
    internal IDongMessage pongMessage;
    public Task Consume(ConsumeContext<IDongMessage> context)

    hitme = true;
    pongMessage = context.Message;
    return Task.CompletedTask;



    public interface IDingMessage

    int MessageId get; set;


    public interface IDongMessage

    int MessageId get; set;




    Is this a good approach for testing a Masstransit consumers?



    If so, do i need to reset the InMemoryTestFixture, somehow, per test fixture?










    share|improve this question


























      2












      2








      2








      Wanting to design my test around a MassTransit Consumer where i can send the consumers messages with a variety of content. Base on the content of the message the consumer will "do work" and relay a messages.



      The problem i have is when running two of these test, in separate test fixtures, there seems to be something interfering with the second test. But run individually each test runs successfully.



      After looking through the MassTransit Test project i have come up with some example test code to demonstrate the problem i'm having.



       [TestFixture]
      public class PingPongMessageTestFixture : InMemoryTestFixture

      private PongConsumer _pongConsumer;
      protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator)

      _received = Handled<IPongMessage>(configurator);


      protected override void PreCreateBus(IInMemoryBusFactoryConfigurator configurator)

      var _pingConsumer = new PingConsumer();
      _pongConsumer = new PongConsumer();
      configurator.ReceiveEndpoint("test_ping_queue", e =>

      e.Consumer(() => _pingConsumer);
      );

      configurator.ReceiveEndpoint("test_pong_queue", e =>

      e.Consumer(() => _pongConsumer);
      );


      Task<ConsumeContext<IPongMessage>> _received;

      [Test]
      public async Task test_how_to_test_consumers()

      await Bus.Publish<IPingMessage>(new MessageId = 100 );
      await _received;

      Assert.IsTrue(_pongConsumer.hitme);
      Assert.AreEqual(100, _pongConsumer.pongMessage.MessageId);


      public class PingConsumer : IConsumer<IPingMessage>

      public Task Consume(ConsumeContext<IPingMessage> context)

      context.Publish<IPongMessage>(new context.Message.MessageId );
      return Task.CompletedTask;



      public class PongConsumer : IConsumer<IPongMessage>

      internal bool hitme;
      internal IPongMessage pongMessage;
      public Task Consume(ConsumeContext<IPongMessage> context)

      hitme = true;
      pongMessage = context.Message;
      return Task.CompletedTask;



      public interface IPingMessage

      int MessageId get; set;


      public interface IPongMessage

      int MessageId get; set;




      this test will send a message to the ping consumer which itself will send a message to the pong consumer.



      This by itself works and tests that the ping consumer will send a pong message. In a real life scenario the "ping" consumer to send Update messages to another service and the pong consumer is just a test consumer used with the tests.



      If i have a second test fixture, which for this questions is very similar, it will fail when both test are run together. though individually it will pass.



      The test does the same thing



      [TestFixture]
      public class DingDongMessageTestFixture : InMemoryTestFixture

      private DongConsumer _pongConsumer;
      protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator)

      _received = Handled<IDongMessage>(configurator);


      protected override void PreCreateBus(IInMemoryBusFactoryConfigurator configurator)

      var _dingConsumer = new DingConsumer();
      _dongConsumer = new DongConsumer();
      configurator.ReceiveEndpoint("test_ding_queue", e =>

      e.Consumer(() => _dingConsumer);
      );

      configurator.ReceiveEndpoint("test_dong_queue", e =>

      e.Consumer(() => _dongConsumer);
      );


      Task<ConsumeContext<IDongMessage>> _received;

      [Test]
      public async Task test_how_to_test_consumers()

      await Bus.Publish<IDingMessage>(new MessageId = 100 );
      await _received;

      Assert.IsTrue(_pongConsumer.hitme);
      Assert.AreEqual(100, _pongConsumer.pongMessage.MessageId);


      public class DingConsumer : IConsumer<IDingMessage>

      public Task Consume(ConsumeContext<IDingMessage> context)

      context.Publish<IDongMessage>(new context.Message.MessageId );
      return Task.CompletedTask;



      public class DongConsumer : IConsumer<IDongMessage>

      internal bool hitme;
      internal IDongMessage pongMessage;
      public Task Consume(ConsumeContext<IDongMessage> context)

      hitme = true;
      pongMessage = context.Message;
      return Task.CompletedTask;



      public interface IDingMessage

      int MessageId get; set;


      public interface IDongMessage

      int MessageId get; set;




      Is this a good approach for testing a Masstransit consumers?



      If so, do i need to reset the InMemoryTestFixture, somehow, per test fixture?










      share|improve this question
















      Wanting to design my test around a MassTransit Consumer where i can send the consumers messages with a variety of content. Base on the content of the message the consumer will "do work" and relay a messages.



      The problem i have is when running two of these test, in separate test fixtures, there seems to be something interfering with the second test. But run individually each test runs successfully.



      After looking through the MassTransit Test project i have come up with some example test code to demonstrate the problem i'm having.



       [TestFixture]
      public class PingPongMessageTestFixture : InMemoryTestFixture

      private PongConsumer _pongConsumer;
      protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator)

      _received = Handled<IPongMessage>(configurator);


      protected override void PreCreateBus(IInMemoryBusFactoryConfigurator configurator)

      var _pingConsumer = new PingConsumer();
      _pongConsumer = new PongConsumer();
      configurator.ReceiveEndpoint("test_ping_queue", e =>

      e.Consumer(() => _pingConsumer);
      );

      configurator.ReceiveEndpoint("test_pong_queue", e =>

      e.Consumer(() => _pongConsumer);
      );


      Task<ConsumeContext<IPongMessage>> _received;

      [Test]
      public async Task test_how_to_test_consumers()

      await Bus.Publish<IPingMessage>(new MessageId = 100 );
      await _received;

      Assert.IsTrue(_pongConsumer.hitme);
      Assert.AreEqual(100, _pongConsumer.pongMessage.MessageId);


      public class PingConsumer : IConsumer<IPingMessage>

      public Task Consume(ConsumeContext<IPingMessage> context)

      context.Publish<IPongMessage>(new context.Message.MessageId );
      return Task.CompletedTask;



      public class PongConsumer : IConsumer<IPongMessage>

      internal bool hitme;
      internal IPongMessage pongMessage;
      public Task Consume(ConsumeContext<IPongMessage> context)

      hitme = true;
      pongMessage = context.Message;
      return Task.CompletedTask;



      public interface IPingMessage

      int MessageId get; set;


      public interface IPongMessage

      int MessageId get; set;




      this test will send a message to the ping consumer which itself will send a message to the pong consumer.



      This by itself works and tests that the ping consumer will send a pong message. In a real life scenario the "ping" consumer to send Update messages to another service and the pong consumer is just a test consumer used with the tests.



      If i have a second test fixture, which for this questions is very similar, it will fail when both test are run together. though individually it will pass.



      The test does the same thing



      [TestFixture]
      public class DingDongMessageTestFixture : InMemoryTestFixture

      private DongConsumer _pongConsumer;
      protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator)

      _received = Handled<IDongMessage>(configurator);


      protected override void PreCreateBus(IInMemoryBusFactoryConfigurator configurator)

      var _dingConsumer = new DingConsumer();
      _dongConsumer = new DongConsumer();
      configurator.ReceiveEndpoint("test_ding_queue", e =>

      e.Consumer(() => _dingConsumer);
      );

      configurator.ReceiveEndpoint("test_dong_queue", e =>

      e.Consumer(() => _dongConsumer);
      );


      Task<ConsumeContext<IDongMessage>> _received;

      [Test]
      public async Task test_how_to_test_consumers()

      await Bus.Publish<IDingMessage>(new MessageId = 100 );
      await _received;

      Assert.IsTrue(_pongConsumer.hitme);
      Assert.AreEqual(100, _pongConsumer.pongMessage.MessageId);


      public class DingConsumer : IConsumer<IDingMessage>

      public Task Consume(ConsumeContext<IDingMessage> context)

      context.Publish<IDongMessage>(new context.Message.MessageId );
      return Task.CompletedTask;



      public class DongConsumer : IConsumer<IDongMessage>

      internal bool hitme;
      internal IDongMessage pongMessage;
      public Task Consume(ConsumeContext<IDongMessage> context)

      hitme = true;
      pongMessage = context.Message;
      return Task.CompletedTask;



      public interface IDingMessage

      int MessageId get; set;


      public interface IDongMessage

      int MessageId get; set;




      Is this a good approach for testing a Masstransit consumers?



      If so, do i need to reset the InMemoryTestFixture, somehow, per test fixture?







      unit-testing masstransit






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 14:26









      derloopkat

      4,19192734




      4,19192734










      asked Oct 24 '17 at 12:52









      theHaggistheHaggis

      323416




      323416






















          1 Answer
          1






          active

          oldest

          votes


















          3














          In your test fixtures, I don't believe there should be any conflict, but because of the interaction with NUnit, there may be something of which I'm unaware because of the base class inheritance that's being used.



          If you use the InMemoryTestHarness directly (the same functionality as the text fixtures, but without any testing framework dependency) I would expect that you should not experience any interactions between two simultaneously executing tests.



          Your approach is the way it should be done, but again, I'd suggesting using the InMemoryTestHarness instead of the fixture.



          An example test is linked: https://github.com/MassTransit/MassTransit/blob/master/src/MassTransit.Tests/Testing/ConsumerTest_Specs.cs






          share|improve this answer























          • How would you hook up a consumer to the test harness that doesn't have a parameterless constructor?

            – theHaggis
            Nov 8 '17 at 11:05











          • this works for me _consumer = _harness.Consumer(() => return (PingConsumer)pingConsumer; );

            – theHaggis
            Nov 8 '17 at 12:22












          • Nice answer! This should be in the documentation somewhere.

            – Gebb
            Aug 6 '18 at 7:35











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46911136%2ftesting-a-masstransit-consumer-using-the-inmemorytestfixture%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          In your test fixtures, I don't believe there should be any conflict, but because of the interaction with NUnit, there may be something of which I'm unaware because of the base class inheritance that's being used.



          If you use the InMemoryTestHarness directly (the same functionality as the text fixtures, but without any testing framework dependency) I would expect that you should not experience any interactions between two simultaneously executing tests.



          Your approach is the way it should be done, but again, I'd suggesting using the InMemoryTestHarness instead of the fixture.



          An example test is linked: https://github.com/MassTransit/MassTransit/blob/master/src/MassTransit.Tests/Testing/ConsumerTest_Specs.cs






          share|improve this answer























          • How would you hook up a consumer to the test harness that doesn't have a parameterless constructor?

            – theHaggis
            Nov 8 '17 at 11:05











          • this works for me _consumer = _harness.Consumer(() => return (PingConsumer)pingConsumer; );

            – theHaggis
            Nov 8 '17 at 12:22












          • Nice answer! This should be in the documentation somewhere.

            – Gebb
            Aug 6 '18 at 7:35















          3














          In your test fixtures, I don't believe there should be any conflict, but because of the interaction with NUnit, there may be something of which I'm unaware because of the base class inheritance that's being used.



          If you use the InMemoryTestHarness directly (the same functionality as the text fixtures, but without any testing framework dependency) I would expect that you should not experience any interactions between two simultaneously executing tests.



          Your approach is the way it should be done, but again, I'd suggesting using the InMemoryTestHarness instead of the fixture.



          An example test is linked: https://github.com/MassTransit/MassTransit/blob/master/src/MassTransit.Tests/Testing/ConsumerTest_Specs.cs






          share|improve this answer























          • How would you hook up a consumer to the test harness that doesn't have a parameterless constructor?

            – theHaggis
            Nov 8 '17 at 11:05











          • this works for me _consumer = _harness.Consumer(() => return (PingConsumer)pingConsumer; );

            – theHaggis
            Nov 8 '17 at 12:22












          • Nice answer! This should be in the documentation somewhere.

            – Gebb
            Aug 6 '18 at 7:35













          3












          3








          3







          In your test fixtures, I don't believe there should be any conflict, but because of the interaction with NUnit, there may be something of which I'm unaware because of the base class inheritance that's being used.



          If you use the InMemoryTestHarness directly (the same functionality as the text fixtures, but without any testing framework dependency) I would expect that you should not experience any interactions between two simultaneously executing tests.



          Your approach is the way it should be done, but again, I'd suggesting using the InMemoryTestHarness instead of the fixture.



          An example test is linked: https://github.com/MassTransit/MassTransit/blob/master/src/MassTransit.Tests/Testing/ConsumerTest_Specs.cs






          share|improve this answer













          In your test fixtures, I don't believe there should be any conflict, but because of the interaction with NUnit, there may be something of which I'm unaware because of the base class inheritance that's being used.



          If you use the InMemoryTestHarness directly (the same functionality as the text fixtures, but without any testing framework dependency) I would expect that you should not experience any interactions between two simultaneously executing tests.



          Your approach is the way it should be done, but again, I'd suggesting using the InMemoryTestHarness instead of the fixture.



          An example test is linked: https://github.com/MassTransit/MassTransit/blob/master/src/MassTransit.Tests/Testing/ConsumerTest_Specs.cs







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 24 '17 at 16:34









          Chris PattersonChris Patterson

          9,09712630




          9,09712630












          • How would you hook up a consumer to the test harness that doesn't have a parameterless constructor?

            – theHaggis
            Nov 8 '17 at 11:05











          • this works for me _consumer = _harness.Consumer(() => return (PingConsumer)pingConsumer; );

            – theHaggis
            Nov 8 '17 at 12:22












          • Nice answer! This should be in the documentation somewhere.

            – Gebb
            Aug 6 '18 at 7:35

















          • How would you hook up a consumer to the test harness that doesn't have a parameterless constructor?

            – theHaggis
            Nov 8 '17 at 11:05











          • this works for me _consumer = _harness.Consumer(() => return (PingConsumer)pingConsumer; );

            – theHaggis
            Nov 8 '17 at 12:22












          • Nice answer! This should be in the documentation somewhere.

            – Gebb
            Aug 6 '18 at 7:35
















          How would you hook up a consumer to the test harness that doesn't have a parameterless constructor?

          – theHaggis
          Nov 8 '17 at 11:05





          How would you hook up a consumer to the test harness that doesn't have a parameterless constructor?

          – theHaggis
          Nov 8 '17 at 11:05













          this works for me _consumer = _harness.Consumer(() => return (PingConsumer)pingConsumer; );

          – theHaggis
          Nov 8 '17 at 12:22






          this works for me _consumer = _harness.Consumer(() => return (PingConsumer)pingConsumer; );

          – theHaggis
          Nov 8 '17 at 12:22














          Nice answer! This should be in the documentation somewhere.

          – Gebb
          Aug 6 '18 at 7:35





          Nice answer! This should be in the documentation somewhere.

          – Gebb
          Aug 6 '18 at 7:35



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46911136%2ftesting-a-masstransit-consumer-using-the-inmemorytestfixture%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices

          How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page