-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEndToEndTestBase.cs
More file actions
41 lines (34 loc) · 1.44 KB
/
EndToEndTestBase.cs
File metadata and controls
41 lines (34 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Text;
using System.Text.Json;
using BuslyCLI.Console.Tests.Commands;
using BuslyCLI.Console.Tests.TestHelpers;
using BuslyCLI.Infrastructure.Endpoints;
using BuslyCLI.Infrastructure.Factories;
using NServiceBus.Transport;
using TransportConfig = BuslyCLI.Config.TransportConfig;
namespace BuslyCLI.Console.Tests.EndToEnd;
public abstract class EndToEndTestBase : CommandTestBase
{
protected readonly JsonSerializerOptions _jsonObjectOptions =
new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true };
protected RawEndpoint TestEndpoint;
protected abstract TransportConfig CreateTransportConfig();
[SetUp]
public async Task SetupEndpoint()
{
TestEndpoint = await new RawEndpointFactory()
.CreateRawEndpoint(TestEndpointNameGenerator.GenerateUniqueEndpointName(), CreateTransportConfig());
await TestEndpoint.StartEndpoint();
}
[TearDown]
public async Task TearDown()
{
await TestEndpoint.ShutDownAndCleanUp();
}
protected static void AssertMessageReceived(IncomingMessage message, string enclosedMessageType, string expectedBody)
{
Assert.That(message.Headers["NServiceBus.EnclosedMessageTypes"], Is.EqualTo(enclosedMessageType));
Assert.That(message.Headers["NServiceBus.ContentType"], Is.EqualTo("application/json"));
Assert.That(Encoding.UTF8.GetString(message.Body.Span), Is.EqualTo(expectedBody));
}
}