Skip to content

Commit

Permalink
Make ReceiveFaultEvent serializable so that it can work with the bina…
Browse files Browse the repository at this point in the history
…ry serializer
  • Loading branch information
vermeeca authored and phatboyg committed Apr 27, 2016
1 parent e74e912 commit d897748
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
52 changes: 52 additions & 0 deletions src/MassTransit.Tests/SerializationFault_Specs.cs
Expand Up @@ -13,6 +13,7 @@
namespace MassTransit.Tests
{
using System;
using System.Linq;
using System.Net.Mime;
using System.Runtime.Serialization;
using System.Threading.Tasks;
Expand Down Expand Up @@ -55,6 +56,57 @@ protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConf
}
}

[TestFixture]
public class When_a_message_response_fails_to_serialize_properly_and_is_using_the_binary_serializer :
InMemoryTestFixture
{
[Serializable]
public class PingMessage2 { }


public class PongMessage2
{
}

Task<ConsumeContext<PingMessage2>> _handled;
Task<ConsumeContext<ReceiveFault>> _faulted;

[Test]
public async Task It_should_respond_with_a_fault_indicating_that_the_type_could_not_be_serialized()
{
var faultContext = await _faulted;

Assert.That(faultContext.Message.Exceptions.First().Message.Contains("PongMessage2"));
}

IRequestClient<PingMessage2, PongMessage2> _requestClient;
Task<PongMessage2> _response;

[TestFixtureSetUp]
public void Setup()
{
_requestClient = CreateRequestClient<PingMessage2, PongMessage2>();

_response = _requestClient.Request(new PingMessage2());
}

protected override void ConfigureBus(IInMemoryBusFactoryConfigurator configurator)
{
configurator.UseBinarySerializer();
}

protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
{
Handler<PingMessage2>(configurator, async context =>
{
context.Respond(new PongMessage2());
});

_faulted = Handled<ReceiveFault>(configurator);
}

}

/// <summary>
/// this requires debugger tricks to make it work
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/MassTransit/Events/ReceiveFaultEvent.cs
Expand Up @@ -15,7 +15,7 @@ namespace MassTransit.Events
using System;
using System.Linq;


[Serializable]
public class ReceiveFaultEvent :
ReceiveFault
{
Expand Down

0 comments on commit d897748

Please sign in to comment.