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
39 changes: 23 additions & 16 deletions src/ClearHostedEndpoint.SqlServerTransport/Examples.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
using ClearMeasure.HostedEndpoint;
using ClearMeasure.HostedEndpoint.SqlServerTransport;
using NServiceBus;

namespace YourNamespace;

/// <summary>
/// Example of a simple NServiceBus endpoint using SQL Server transport.
/// </summary>
public class SimpleEndpoint : ClearHostedEndpoint
{
using ClearMeasure.HostedEndpoint;
using ClearMeasure.HostedEndpoint.SqlServerTransport;
using Microsoft.Extensions.Configuration;
using NServiceBus;

namespace YourNamespace;

/// <summary>
/// Example of a simple NServiceBus endpoint using SQL Server transport.
/// </summary>
public class SimpleEndpoint : ClearHostedEndpoint
{
public SimpleEndpoint(IConfiguration configuration) : base(configuration)

Check warning on line 13 in src/ClearHostedEndpoint.SqlServerTransport/Examples.cs

View workflow job for this annotation

GitHub Actions / Build and Test

Missing XML comment for publicly visible type or member 'SimpleEndpoint.SimpleEndpoint(IConfiguration)'
{
}
protected override void ConfigureTransport(EndpointConfiguration endpointConfiguration)

Check warning on line 16 in src/ClearHostedEndpoint.SqlServerTransport/Examples.cs

View workflow job for this annotation

GitHub Actions / Build and Test

Missing XML comment for publicly visible type or member 'SimpleEndpoint.ConfigureTransport(EndpointConfiguration)'
{
// Single line configuration with SQL Server transport
endpointConfiguration.UseSqlServerTransport("Server=localhost;Database=MyApp;Integrated Security=true;");
}
}

/// <summary>
/// Example with custom transport options.
/// </summary>
public class CustomEndpoint : ClearHostedEndpoint
{
/// <summary>
/// Example with custom transport options.
/// </summary>
public class CustomEndpoint : ClearHostedEndpoint
{
public CustomEndpoint(IConfiguration configuration) : base(configuration)
{
}
protected override void ConfigureTransport(EndpointConfiguration endpointConfiguration)
{
var options = new SqlServerTransportOptions
Expand Down
20 changes: 10 additions & 10 deletions src/ClearHostedEndpoint.Tests/ClearHostedEndpointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ClearHostedEndpointTests
public async Task StartAsync_WithLearningTransport_ShouldStartSuccessfully()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

try
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public async Task StartAsync_WithLearningTransport_ShouldStartSuccessfully()
public async Task StartAsync_ShouldCallLifecycleMethods_InCorrectOrder()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());
var callOrder = new List<string>();

try
Expand All @@ -64,7 +64,7 @@ public async Task StartAsync_ShouldCallLifecycleMethods_InCorrectOrder()
public async Task EndpointInstance_BeforeStart_ShouldThrowInvalidOperationException()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

// Act & Assert
var act = () =>
Expand All @@ -84,7 +84,7 @@ public async Task EndpointInstance_BeforeStart_ShouldThrowInvalidOperationExcept
public async Task StopAsync_ShouldStopEndpoint_Gracefully()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

try
{
Expand All @@ -106,7 +106,7 @@ public async Task StopAsync_ShouldStopEndpoint_Gracefully()
public void EffectiveEndpointName_WithNoCustomName_ShouldUseTypeName()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

// Act
var effectiveName = endpoint.GetType()
Expand All @@ -124,7 +124,7 @@ public void EffectiveEndpointName_WithCustomName_ShouldUseCustomName()
{
// Arrange
var customName = "MyCustomEndpoint";
var endpoint = new CustomNamedEndpoint(customName);
var endpoint = new CustomNamedEndpoint(TestHelpers.CreateTestConfiguration(), customName);

// Act
var effectiveName = endpoint.GetType()
Expand All @@ -141,7 +141,7 @@ public void EffectiveEndpointName_WithCustomName_ShouldUseCustomName()
public async Task StartAsync_WithFaultyTransport_ShouldThrowEndpointConfigurationException()
{
// Arrange
var endpoint = new FaultyTransportEndpoint();
var endpoint = new FaultyTransportEndpoint(TestHelpers.CreateTestConfiguration());

// Act
var act = async () => await endpoint.StartAsync(CancellationToken.None);
Expand All @@ -157,7 +157,7 @@ await act.Should().ThrowAsync<EndpointConfigurationException>()
public async Task ExecuteAsync_ShouldKeepServiceAlive_UntilCancellationRequested()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());
var cts = new CancellationTokenSource();

try
Expand All @@ -184,7 +184,7 @@ public async Task ExecuteAsync_ShouldKeepServiceAlive_UntilCancellationRequested
public void Dispose_ShouldCleanupResources()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

// Act
endpoint.Dispose();
Expand All @@ -196,7 +196,7 @@ public void Dispose_ShouldCleanupResources()
public void Dispose_CalledMultipleTimes_ShouldNotThrow()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

// Act
endpoint.Dispose();
Expand Down
14 changes: 7 additions & 7 deletions src/ClearHostedEndpoint.Tests/CustomConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class CustomConfigurationTests
public async Task CustomRecoverabilityEndpoint_ShouldUseCustomRetrySettings()
{
// Arrange
var endpoint = new CustomRecoverabilityEndpoint
var endpoint = new CustomRecoverabilityEndpoint(TestHelpers.CreateTestConfiguration())
{
CustomImmediateRetries = 5,
CustomDelayedRetries = 10
Expand All @@ -35,7 +35,7 @@ public async Task CustomNamedEndpoint_ShouldUseProvidedName()
{
// Arrange
var customName = "MyCustomEndpoint";
var endpoint = new CustomNamedEndpoint(customName);
var endpoint = new CustomNamedEndpoint(TestHelpers.CreateTestConfiguration(), customName);

try
{
Expand Down Expand Up @@ -66,7 +66,7 @@ public void CreateDbConnection_ShouldCreateValidConnection()
{
ConnectionString = "Server=localhost;Database=Test;"
};
var endpoint = new SqlPersistenceEndpoint(sqlOptions);
var endpoint = new SqlPersistenceEndpoint(TestHelpers.CreateTestConfiguration(), sqlOptions);
var connectionString = "Server=localhost;Database=Test;";

// Act
Expand All @@ -86,7 +86,7 @@ public void CreateDbConnection_ShouldCreateValidConnection()
public async Task Endpoint_WithCustomSerialization_CanOverrideDefault()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

try
{
Expand All @@ -108,7 +108,7 @@ public async Task Endpoint_WithCustomSerialization_CanOverrideDefault()
public async Task Endpoint_ConfigureEndpointAsync_AllowsAsyncConfiguration()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

try
{
Expand All @@ -134,7 +134,7 @@ public async Task Endpoint_ConfigureEndpointAsync_AllowsAsyncConfiguration()
public async Task Endpoint_WithVariousNames_ShouldHandleCorrectly(string endpointName)
{
// Arrange
var endpoint = new CustomNamedEndpoint(endpointName);
var endpoint = new CustomNamedEndpoint(TestHelpers.CreateTestConfiguration(), endpointName);

try
{
Expand Down Expand Up @@ -170,7 +170,7 @@ public async Task Endpoint_WithComplexConfiguration_ShouldHandleAllSettings()
EnableOutbox = false
};

var endpoint = new TestEndpoint(endpointOptions: endpointOptions);
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration(), endpointOptions: endpointOptions);

try
{
Expand Down
10 changes: 5 additions & 5 deletions src/ClearHostedEndpoint.Tests/DependencyInjectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class DependencyInjectionTests
public async Task Endpoint_WithRegisteredDependencies_ShouldResolveServices()
{
// Arrange
var endpoint = new DependencyInjectionEndpoint();
var endpoint = new DependencyInjectionEndpoint(TestHelpers.CreateTestConfiguration());

try
{
Expand All @@ -32,8 +32,8 @@ public async Task Endpoint_WithRegisteredDependencies_ShouldResolveServices()
public async Task Endpoint_ShouldHaveIsolatedServiceProvider()
{
// Arrange
var endpoint1 = new DependencyInjectionEndpoint();
var endpoint2 = new DependencyInjectionEndpoint();
var endpoint1 = new DependencyInjectionEndpoint(TestHelpers.CreateTestConfiguration());
var endpoint2 = new DependencyInjectionEndpoint(TestHelpers.CreateTestConfiguration());

try
{
Expand All @@ -57,7 +57,7 @@ public async Task Endpoint_ShouldHaveIsolatedServiceProvider()
public async Task RegisterDependencyInjection_ShouldBeCalledDuringStartup()
{
// Arrange
var endpoint = new DependencyInjectionEndpoint();
var endpoint = new DependencyInjectionEndpoint(TestHelpers.CreateTestConfiguration());

try
{
Expand All @@ -78,7 +78,7 @@ public async Task RegisterDependencyInjection_ShouldBeCalledDuringStartup()
public void CreateServiceCollection_ShouldReturnNewServiceCollection()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

// Act
var method = endpoint.GetType()
Expand Down
16 changes: 9 additions & 7 deletions src/ClearHostedEndpoint.Tests/EndpointIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class EndpointIntegrationTests
public async Task FullLifecycle_StartWorkStop_ShouldCompleteSuccessfully()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

try
{
Expand All @@ -36,10 +36,12 @@ public async Task MultipleEndpoints_WithDifferentConfigurations_ShouldRunIndepen
{
// Arrange
var endpoint1 = new TestEndpoint(
TestHelpers.CreateTestConfiguration(),
endpointOptions: new EndpointOptions { EndpointName = "Endpoint1" });
var endpoint2 = new TestEndpoint(
TestHelpers.CreateTestConfiguration(),
endpointOptions: new EndpointOptions { EndpointName = "Endpoint2", MaxConcurrency = 5 });
var endpoint3 = new CustomNamedEndpoint("Endpoint3");
var endpoint3 = new CustomNamedEndpoint(TestHelpers.CreateTestConfiguration(), "Endpoint3");

try
{
Expand Down Expand Up @@ -70,7 +72,7 @@ public async Task MultipleEndpoints_WithDifferentConfigurations_ShouldRunIndepen
public async Task Endpoint_WithLongRunningWork_ShouldCancelGracefully()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());
var cts = new CancellationTokenSource();

try
Expand Down Expand Up @@ -106,8 +108,8 @@ public async Task Endpoint_WithAllFeatures_ShouldStartAndStopSuccessfully()
DelayedRetryCount = 2
};

var endpoint = new DependencyInjectionEndpoint();
var customEndpointWithOptions = new TestEndpoint(endpointOptions: endpointOptions);
var endpoint = new DependencyInjectionEndpoint(TestHelpers.CreateTestConfiguration());
var customEndpointWithOptions = new TestEndpoint(TestHelpers.CreateTestConfiguration(), endpointOptions: endpointOptions);

try
{
Expand Down Expand Up @@ -163,7 +165,7 @@ public async Task Endpoint_RestartAfterStop_ShouldWorkCorrectly()
public async Task Endpoint_WithCustomRecoverability_ShouldApplySettings()
{
// Arrange
var endpoint = new CustomRecoverabilityEndpoint
var endpoint = new CustomRecoverabilityEndpoint(TestHelpers.CreateTestConfiguration())
{
CustomImmediateRetries = 7,
CustomDelayedRetries = 3
Expand All @@ -188,7 +190,7 @@ public async Task Endpoint_WithCustomRecoverability_ShouldApplySettings()
public async Task Endpoint_WithCancellationDuringStartup_ShouldHandleGracefully()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());
var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(100));

try
Expand Down
18 changes: 9 additions & 9 deletions src/ClearHostedEndpoint.Tests/EndpointLifecycleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class EndpointLifecycleTests
public async Task StartAsync_ThenStopAsync_ShouldCompleteSuccessfully()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

// Act & Assert
await endpoint.StartAsync(CancellationToken.None);
Expand All @@ -23,7 +23,7 @@ public async Task StartAsync_ThenStopAsync_ShouldCompleteSuccessfully()
public async Task OnStoppingAsync_ShouldBeCalledDuringShutdown()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

try
{
Expand All @@ -47,7 +47,7 @@ public async Task OnStoppingAsync_ShouldBeCalledDuringShutdown()
public async Task StopAsync_WithCancellationToken_ShouldRespectCancellation()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());
var cts = new CancellationTokenSource();

try
Expand All @@ -71,7 +71,7 @@ public async Task StopAsync_WithCancellationToken_ShouldRespectCancellation()
public async Task Dispose_AfterStop_ShouldNotThrow()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

await endpoint.StartAsync(CancellationToken.None);
await Task.Delay(500);
Expand All @@ -87,7 +87,7 @@ public async Task Dispose_AfterStop_ShouldNotThrow()
public async Task Dispose_WithoutStop_ShouldNotThrow()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

await endpoint.StartAsync(CancellationToken.None);
await Task.Delay(500);
Expand All @@ -102,7 +102,7 @@ public async Task Dispose_WithoutStop_ShouldNotThrow()
public void Dispose_WithoutStart_ShouldNotThrow()
{
// Arrange
var endpoint = new TestEndpoint();
var endpoint = new TestEndpoint(TestHelpers.CreateTestConfiguration());

// Act
endpoint.Dispose();
Expand All @@ -114,9 +114,9 @@ public void Dispose_WithoutStart_ShouldNotThrow()
public async Task MultipleEndpoints_CanRunConcurrently()
{
// Arrange
var endpoint1 = new TestEndpoint();
var endpoint2 = new TestEndpoint();
var endpoint3 = new TestEndpoint();
var endpoint1 = new TestEndpoint(TestHelpers.CreateTestConfiguration());
var endpoint2 = new TestEndpoint(TestHelpers.CreateTestConfiguration());
var endpoint3 = new TestEndpoint(TestHelpers.CreateTestConfiguration());

try
{
Expand Down
Loading
Loading