Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public Task Configure(string endpointName, EndpointConfiguration configuration,
recoverability.Immediate(config => config.NumberOfRetries(0));
recoverability.Delayed(config => config.NumberOfRetries(0));

configuration.Pipeline.Register("TestIndependenceHeaderBehavior", typeof(TestIndependenceHeaderBehavior), "Appends the TestRunId to outgoing messages");
configuration.Pipeline.Register("TestIndependenceSkipBehavior", typeof(TestIndependenceSkipBehavior), "Skips messages not created during the current test.");

configuration.EnableTestIndependence();
configuration.EnforcePublisherMetadataRegistration(endpointName, publisherMetadata);

return Task.CompletedTask;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[*.cs]

# Justification: Test project
dotnet_diagnostic.CA2007.severity = suggestion
dotnet_diagnostic.PS0018.severity = suggestion
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
namespace NServiceBus.AcceptanceTests.CloudEvents;

using AcceptanceTesting;
using Configuration.AdvancedExtensibility;
using EndpointTemplates;
using Envelope.CloudEvents;
using NServiceBus.Pipeline;
using NUnit.Framework;
using Transport;
Expand Down Expand Up @@ -34,8 +32,7 @@ public async Task An_amqp_binary_cloud_event_is_received()
Sequencer = "000000000000000000000000000099240000000000c41c18"
});
}))
.Done(c => c.MessageReceived)
.Run().ConfigureAwait(false);
.Run();

using (Assert.EnterMultipleScope())
{
Expand Down Expand Up @@ -66,17 +63,15 @@ public Task Invoke(IDispatchContext context, Func<IDispatchContext, Task> next)
}
}

class Context : ScenarioContext
public class Context : ScenarioContext
{
public bool MessageReceived { get; set; }
public string MessageId { get; set; }
public Dictionary<string, string> Headers { get; set; }
}

class Endpoint : EndpointConfigurationBuilder
public class Endpoint : EndpointConfigurationBuilder
{
public Endpoint()
{
public Endpoint() =>
EndpointSetup<DefaultServer>(c =>
{
var config = c.GetCloudEventsConfiguration();
Expand All @@ -85,15 +80,15 @@ public Endpoint()
c.Pipeline.Register("CustomSerializationBehavior", new CustomSerializationBehavior(),
"Serializing message");
});
}

class Handler(Context testContext) : IHandleMessages<Message>
[Handler]
public class Handler(Context testContext) : IHandleMessages<Message>
{
public Task Handle(Message message, IMessageHandlerContext context)
{
testContext.MessageId = context.MessageId;
testContext.Headers = context.MessageHeaders.ToDictionary(x => x.Key, x => x.Value);
testContext.MessageReceived = true;
testContext.MarkAsCompleted();

return Task.CompletedTask;
}
Expand All @@ -113,4 +108,4 @@ public class Message : IMessage
public string Url { get; set; }
public string Sequencer { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
namespace NServiceBus.AcceptanceTests.CloudEvents;

using AcceptanceTesting;
using Configuration.AdvancedExtensibility;
using EndpointTemplates;
using Envelope.CloudEvents;
using NServiceBus.Pipeline;
using NUnit.Framework;
using Transport;
Expand Down Expand Up @@ -34,8 +32,7 @@ public async Task An_http_binary_cloud_event_is_received()
Sequencer = "000000000000000000000000000099240000000000c41c18"
});
}))
.Done(c => c.MessageReceived)
.Run().ConfigureAwait(false);
.Run();

using (Assert.EnterMultipleScope())
{
Expand Down Expand Up @@ -66,17 +63,15 @@ public Task Invoke(IDispatchContext context, Func<IDispatchContext, Task> next)
}
}

class Context : ScenarioContext
public class Context : ScenarioContext
{
public bool MessageReceived { get; set; }
public string MessageId { get; set; }
public Dictionary<string, string> Headers { get; set; }
}

class Endpoint : EndpointConfigurationBuilder
public class Endpoint : EndpointConfigurationBuilder
{
public Endpoint()
{
public Endpoint() =>
EndpointSetup<DefaultServer>(c =>
{
var config = c.GetCloudEventsConfiguration();
Expand All @@ -85,22 +80,21 @@ public Endpoint()
c.Pipeline.Register("CustomSerializationBehavior", new CustomSerializationBehavior(),
"Serializing message");
});
}

class Handler(Context testContext) : IHandleMessages<Message>
[Handler]
public class Handler(Context testContext) : IHandleMessages<Message>
{
public Task Handle(Message message, IMessageHandlerContext context)
{
testContext.MessageId = context.MessageId;
testContext.Headers = context.MessageHeaders.ToDictionary(x => x.Key, x => x.Value);
testContext.MessageReceived = true;
testContext.MarkAsCompleted();

return Task.CompletedTask;
}
}
}


public class Message : IMessage
{
public string Api { get; set; }
Expand All @@ -113,4 +107,4 @@ public class Message : IMessage
public string Url { get; set; }
public string Sequencer { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
namespace NServiceBus.AcceptanceTests.CloudEvents;

using AcceptanceTesting;
using Configuration.AdvancedExtensibility;
using EndpointTemplates;
using Envelope.CloudEvents;
using NServiceBus.Pipeline;
using NUnit.Framework;
using Transport;
Expand Down Expand Up @@ -42,8 +40,7 @@ public async Task A_json_structured_cloud_event_is_received()
}
});
}))
.Done(c => c.MessageReceived)
.Run().ConfigureAwait(false);
.Run();

using (Assert.EnterMultipleScope())
{
Expand All @@ -68,17 +65,15 @@ public Task Invoke(IDispatchContext context, Func<IDispatchContext, Task> next)
}
}

class Context : ScenarioContext
public class Context : ScenarioContext
{
public bool MessageReceived { get; set; }
public string MessageId { get; set; }
public Dictionary<string, string> Headers { get; set; }
}

class Endpoint : EndpointConfigurationBuilder
public class Endpoint : EndpointConfigurationBuilder
{
public Endpoint()
{
public Endpoint() =>
EndpointSetup<DefaultServer>(c =>
{
var config = c.GetCloudEventsConfiguration();
Expand All @@ -87,15 +82,15 @@ public Endpoint()
c.Pipeline.Register("CustomSerializationBehavior", new CustomSerializationBehavior(),
"Serializing message");
});
}

class Handler(Context testContext) : IHandleMessages<Message>
[Handler]
public class Handler(Context testContext) : IHandleMessages<Message>
{
public Task Handle(Message message, IMessageHandlerContext context)
{
testContext.MessageId = context.MessageId;
testContext.Headers = context.MessageHeaders.ToDictionary(x => x.Key, x => x.Value);
testContext.MessageReceived = true;
testContext.MarkAsCompleted();

return Task.CompletedTask;
}
Expand Down Expand Up @@ -125,4 +120,4 @@ public class Message : IMessage
public string Subject { get; set; }
public NestedData Data { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
namespace NServiceBus.AcceptanceTests;

using AcceptanceTesting.Customization;
using AcceptanceTesting.Support;
using NUnit.Framework;

public class ConfigureEndpointAcceptanceTestingTransportWithCloudEvents(
bool useNativePubSub,
Expand All @@ -11,68 +9,14 @@ public class ConfigureEndpointAcceptanceTestingTransportWithCloudEvents(
bool? enforcePublisherMetadata = null)
: IConfigureEndpointTestExecution
{
public Task Cleanup()
{
try
{
if (Directory.Exists(storageDir))
{
Directory.Delete(storageDir, true);
}
}
catch
{
// ignored
}
readonly ConfigureEndpointAcceptanceTestingTransport transport = new(useNativePubSub, useNativeDelayedDelivery, transactionMode, enforcePublisherMetadata);

return Task.CompletedTask;
}
public Task Cleanup() => transport.Cleanup();

public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings,
PublisherMetadata publisherMetadata)
{
var testRunId = TestContext.CurrentContext.Test.ID;

string tempDir =
//can't use bin dir since that will be too long on the build agents
Environment.OSVersion.Platform == PlatformID.Win32NT ? @"c:\temp" : Path.GetTempPath();

storageDir = Path.Combine(tempDir, "acc", testRunId);

var acceptanceTestingTransport = new AcceptanceTestingTransport(
enableNativeDelayedDelivery: useNativeDelayedDelivery,
enableNativePublishSubscribe: useNativePubSub)
{
StorageLocation = storageDir,
};

if (transactionMode.HasValue)
{
acceptanceTestingTransport.TransportTransactionMode = transactionMode.Value;
}

if (enforcePublisherMetadata.GetValueOrDefault(false))
{
configuration.EnforcePublisherMetadataRegistration(endpointName, publisherMetadata);
}

configuration.EnableCloudEvents();
var routing = configuration.UseTransport(acceptanceTestingTransport);

if (!useNativePubSub)
{
//apply publisher registrations required for message driven pub/sub
foreach (var publisherMetadataPublisher in publisherMetadata.Publishers)
{
foreach (var @event in publisherMetadataPublisher.Events)
{
routing.RegisterPublisher(@event, publisherMetadataPublisher.PublisherName);
}
}
}

return Task.CompletedTask;
return transport.Configure(endpointName, configuration, settings, publisherMetadata);
}

string storageDir;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ public partial class TestSuiteConstraints

public bool SupportsPurgeOnStartup => false;

public IConfigureEndpointTestExecution CreateTransportConfiguration()
{
return new ConfigureEndpointAcceptanceTestingTransportWithCloudEvents(true, true);
}

public IConfigureEndpointTestExecution CreatePersistenceConfiguration()
{
return new ConfigureEndpointAcceptanceTestingPersistence();
}
public IConfigureEndpointTestExecution CreateTransportConfiguration() => new ConfigureEndpointAcceptanceTestingTransportWithCloudEvents(true, true);

public IConfigureEndpointTestExecution CreatePersistenceConfiguration() => new ConfigureEndpointAcceptanceTestingPersistence();
}
Loading