-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
…_bug Prevent Type property on DataBusProperty<T> from being serialized
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
namespace NServiceBus.AcceptanceTests.DataBus | ||
{ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using AcceptanceTesting; | ||
using AcceptanceTesting.Customization; | ||
using EndpointTemplates; | ||
using NUnit.Framework; | ||
|
||
public class When_sending_databus_properties_with_systemjsonserializer : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public async Task Should_receive_messages_with_largepayload_correctly() | ||
{ | ||
var payloadToSend = new byte[PayloadSize]; | ||
|
||
var context = await Scenario.Define<Context>() | ||
.WithEndpoint<Sender>(b => b.When(session => session.Send(new MyMessageWithLargePayload | ||
{ | ||
Payload = new DataBusProperty<byte[]>(payloadToSend) | ||
}))) | ||
.WithEndpoint<Receiver>() | ||
.Done(c => c.ReceivedPayload != null) | ||
.Run(); | ||
|
||
Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be marshalled correctly using the databus"); | ||
} | ||
|
||
const int PayloadSize = 500; | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public byte[] ReceivedPayload { get; set; } | ||
} | ||
|
||
public class Sender : EndpointConfigurationBuilder | ||
{ | ||
public Sender() | ||
{ | ||
EndpointSetup<DefaultServer>(builder => | ||
{ | ||
var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "databus", "sender"); | ||
builder.UseDataBus<FileShareDataBus, SystemJsonDataBusSerializer>().BasePath(basePath); | ||
builder.UseSerialization<SystemJsonSerializer>(); | ||
Check failure on line 44 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Windows
Check failure on line 44 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Windows
Check failure on line 44 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Windows
Check failure on line 44 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Windows
Check failure on line 44 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Windows
Check failure on line 44 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Linux
Check failure on line 44 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Linux
Check failure on line 44 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Linux
Check failure on line 44 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Linux
Check failure on line 44 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Linux
|
||
builder.ConfigureRouting().RouteToEndpoint(typeof(MyMessageWithLargePayload), typeof(Receiver)); | ||
}); | ||
} | ||
} | ||
|
||
public class Receiver : EndpointConfigurationBuilder | ||
{ | ||
public Receiver() | ||
{ | ||
EndpointSetup<DefaultServer>(builder => | ||
{ | ||
var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "databus", "sender"); | ||
builder.UseDataBus<FileShareDataBus, SystemJsonDataBusSerializer>().BasePath(basePath); | ||
builder.UseSerialization<SystemJsonSerializer>(); | ||
Check failure on line 58 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Windows
Check failure on line 58 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Windows
Check failure on line 58 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Windows
Check failure on line 58 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Windows
Check failure on line 58 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Windows
Check failure on line 58 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Linux
Check failure on line 58 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Linux
Check failure on line 58 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Linux
Check failure on line 58 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Linux
Check failure on line 58 in src/NServiceBus.AcceptanceTests/DataBus/When_sending_databus_properties_with_systemjsonserializer.cs GitHub Actions / Linux
|
||
}); | ||
} | ||
|
||
public class MyMessageHandler : IHandleMessages<MyMessageWithLargePayload> | ||
{ | ||
public MyMessageHandler(Context context) | ||
{ | ||
testContext = context; | ||
} | ||
|
||
public Task Handle(MyMessageWithLargePayload messageWithLargePayload, IMessageHandlerContext context) | ||
{ | ||
testContext.ReceivedPayload = messageWithLargePayload.Payload.Value; | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
Context testContext; | ||
} | ||
} | ||
|
||
public class MyMessageWithLargePayload : ICommand | ||
{ | ||
public DataBusProperty<byte[]> Payload { get; set; } | ||
} | ||
} | ||
} |