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

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived