-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35064fa
commit 3859dd0
Showing
14 changed files
with
76 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 31 additions & 14 deletions
45
src/AcceptanceTesting/Infrastructure/EndpointTemplates/ConfigureExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,48 @@ | ||
namespace NServiceBus.AcceptanceTests.EndpointTemplates | ||
{ | ||
using Configuration.AdvancedExtensibility; | ||
using Transport; | ||
using System.Threading.Tasks; | ||
using AcceptanceTesting.Support; | ||
using ObjectBuilder; | ||
using NServiceBus.AcceptanceTesting.Support; | ||
|
||
public static class ConfigureExtensions | ||
{ | ||
public static RoutingSettings ConfigureRouting(this EndpointConfiguration configuration) => | ||
new RoutingSettings(configuration.GetSettings()); | ||
|
||
// This is kind of a hack because the acceptance testing framework doesn't give any access to the transport definition to individual tests. | ||
public static TransportDefinition ConfigureTransport(this EndpointConfiguration configuration) => | ||
configuration.GetSettings().Get<TransportDefinition>(); | ||
|
||
public static TTransportDefinition ConfigureTransport<TTransportDefinition>( | ||
this EndpointConfiguration configuration) | ||
where TTransportDefinition : TransportDefinition => | ||
(TTransportDefinition)configuration.GetSettings().Get<TransportDefinition>(); | ||
|
||
public static async Task DefineTransport(this EndpointConfiguration config, RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizationConfiguration) | ||
{ | ||
var transportConfiguration = TestSuiteConstraints.Current.CreateTransportConfiguration(); | ||
await transportConfiguration.Configure(endpointCustomizationConfiguration.EndpointName, config, runDescriptor.Settings, endpointCustomizationConfiguration.PublisherMetadata); | ||
runDescriptor.OnTestCompleted(_ => transportConfiguration.Cleanup()); | ||
} | ||
|
||
public static async Task DefineTransport(this EndpointConfiguration config, IConfigureEndpointTestExecution transportConfiguration, RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizationConfiguration) | ||
{ | ||
await transportConfiguration.Configure(endpointCustomizationConfiguration.EndpointName, config, runDescriptor.Settings, endpointCustomizationConfiguration.PublisherMetadata); | ||
runDescriptor.OnTestCompleted(_ => transportConfiguration.Cleanup()); | ||
} | ||
|
||
public static async Task DefinePersistence(this EndpointConfiguration config, RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizationConfiguration) | ||
{ | ||
var persistenceConfiguration = TestSuiteConstraints.Current.CreatePersistenceConfiguration(); | ||
await persistenceConfiguration.Configure(endpointCustomizationConfiguration.EndpointName, config, runDescriptor.Settings, endpointCustomizationConfiguration.PublisherMetadata); | ||
runDescriptor.OnTestCompleted(_ => persistenceConfiguration.Cleanup()); | ||
} | ||
|
||
public static void RegisterComponentsAndInheritanceHierarchy(this EndpointConfiguration builder, RunDescriptor runDescriptor) | ||
public static async Task DefinePersistence(this EndpointConfiguration config, IConfigureEndpointTestExecution persistenceConfiguration, RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizationConfiguration) | ||
{ | ||
builder.RegisterComponents(r => { RegisterInheritanceHierarchyOfContextOnContainer(runDescriptor, r); }); | ||
} | ||
|
||
static void RegisterInheritanceHierarchyOfContextOnContainer(RunDescriptor runDescriptor, IConfigureComponents r) | ||
{ | ||
var type = runDescriptor.ScenarioContext.GetType(); | ||
while (type != typeof(object)) | ||
{ | ||
r.RegisterSingleton(type, runDescriptor.ScenarioContext); | ||
type = type.BaseType; | ||
} | ||
await persistenceConfiguration.Configure(endpointCustomizationConfiguration.EndpointName, config, runDescriptor.Settings, endpointCustomizationConfiguration.PublisherMetadata); | ||
runDescriptor.OnTestCompleted(_ => persistenceConfiguration.Cleanup()); | ||
} | ||
} | ||
} |
55 changes: 16 additions & 39 deletions
55
src/AcceptanceTesting/Infrastructure/EndpointTemplates/DefaultServer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,35 @@ | ||
namespace NServiceBus.AcceptanceTests.EndpointTemplates | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using AcceptanceTesting.Customization; | ||
using AcceptanceTesting.Support; | ||
using Configuration.AdvancedExtensibility; | ||
using Features; | ||
|
||
public class DefaultServer : IEndpointSetupTemplate | ||
{ | ||
public DefaultServer() | ||
{ | ||
typesToInclude = new List<Type>(); | ||
} | ||
|
||
public DefaultServer(List<Type> typesToInclude) | ||
{ | ||
this.typesToInclude = typesToInclude; | ||
} | ||
public IConfigureEndpointTestExecution TransportConfiguration { get; set; } = TestSuiteConstraints.Current.CreateTransportConfiguration(); | ||
|
||
#pragma warning disable CS0618 | ||
public async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointConfiguration, Action<EndpointConfiguration> configurationBuilderCustomization) | ||
#pragma warning restore CS0618 | ||
public async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointConfiguration, Func<EndpointConfiguration, Task> configurationBuilderCustomization) | ||
{ | ||
var types = endpointConfiguration.GetTypesScopedByTestClass(); | ||
|
||
typesToInclude.AddRange(types); | ||
|
||
var configuration = new EndpointConfiguration(endpointConfiguration.EndpointName); | ||
|
||
configuration.TypesToIncludeInScan(typesToInclude); | ||
configuration.EnableInstallers(); | ||
|
||
configuration.DisableFeature<TimeoutManager>(); | ||
|
||
var recoverability = configuration.Recoverability(); | ||
recoverability.Delayed(delayed => delayed.NumberOfRetries(0)); | ||
recoverability.Immediate(immediate => immediate.NumberOfRetries(0)); | ||
configuration.SendFailedMessagesTo("error"); | ||
configuration.UseSerialization<NewtonsoftSerializer>(); | ||
var builder = new EndpointConfiguration(endpointConfiguration.EndpointName); | ||
builder.EnableInstallers(); | ||
|
||
configuration.RegisterComponentsAndInheritanceHierarchy(runDescriptor); | ||
builder.Recoverability() | ||
.Delayed(delayed => delayed.NumberOfRetries(0)) | ||
.Immediate(immediate => immediate.NumberOfRetries(0)); | ||
builder.SendFailedMessagesTo("error"); | ||
builder.UseSerialization<NewtonsoftJsonSerializer>(); | ||
|
||
await configuration.DefinePersistence(runDescriptor, endpointConfiguration).ConfigureAwait(false); | ||
await builder.DefineTransport(TransportConfiguration, runDescriptor, endpointConfiguration).ConfigureAwait(false); | ||
|
||
configuration.GetSettings().SetDefault("ScaleOut.UseSingleBrokerQueue", true); | ||
configurationBuilderCustomization(configuration); | ||
await configurationBuilderCustomization(builder).ConfigureAwait(false); | ||
|
||
configuration.Pipeline.Register(new TestRunMarker(runDescriptor.ScenarioContext.TestRunId.ToString()), "Marks messages with test run ID."); | ||
builder.Pipeline.Register(new TestRunMarker(runDescriptor.ScenarioContext.TestRunId.ToString()), "Marks messages with test run ID."); | ||
|
||
return configuration; | ||
} | ||
// scan types at the end so that all types used by the configuration have been loaded into the AppDomain | ||
builder.ScanTypesForTest(endpointConfiguration); | ||
|
||
List<Type> typesToInclude; | ||
return builder; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net461</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<LangVersion>7.1</LangVersion> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<LangVersion>7.1</LangVersion> | ||
<TargetFramework>net48</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="NServiceBus" Version="[7.4.0, 8.0.0)" /> | ||
<PackageReference Include="NServiceBus" Version="8.*" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.