-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathWhen_instance_is_setup.cs
More file actions
93 lines (78 loc) · 3.75 KB
/
When_instance_is_setup.cs
File metadata and controls
93 lines (78 loc) · 3.75 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
namespace ServiceControl.Audit.UnitTests.Infrastructure
{
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading.Tasks;
using Audit.Infrastructure.Hosting;
using Audit.Infrastructure.Hosting.Commands;
using Audit.Infrastructure.Settings;
using Microsoft.Extensions.DependencyInjection;
using NServiceBus;
using NServiceBus.Transport;
using NUnit.Framework;
using Transports;
class When_instance_is_setup
{
[Test]
public async Task Should_provision_queues()
{
var manifest = new TransportManifest
{
Definitions = [new TransportManifestDefinition
{
Name = "FakeTransport",
Location = AppContext.BaseDirectory,
AssemblyName = Assembly.GetExecutingAssembly().GetName().Name,
TypeName = typeof(FakeTransport).AssemblyQualifiedName
}]
};
TransportManifestLibrary.TransportManifests.Add(manifest);
var instanceInputQueueName = "SomeInstanceQueue";
var settings = new Settings("FakeTransport", "InMemory")
{
InstanceName = instanceInputQueueName,
ForwardAuditMessages = true,
AssemblyLoadContextResolver = static _ => AssemblyLoadContext.Default
};
var setupCommand = new SetupCommand();
await setupCommand.Execute(new HostArguments([]), settings);
Assert.That(FakeTransport.QueuesCreated, Is.EquivalentTo(new[]
{
instanceInputQueueName,
$"{instanceInputQueueName}.Errors",
settings.AuditQueue,
settings.AuditLogQueue
}));
}
}
class FakeTransport : ITransportCustomization
{
public static IList<string> QueuesCreated;
public void CustomizePrimaryEndpoint(EndpointConfiguration endpointConfiguration,
TransportSettings transportSettings) => throw new NotImplementedException();
public void AddTransportForPrimary(IServiceCollection services, TransportSettings transportSettings) => throw new NotImplementedException();
public void CustomizeAuditEndpoint(EndpointConfiguration endpointConfiguration,
TransportSettings transportSettings) => throw new NotImplementedException();
public void AddTransportForAudit(IServiceCollection services, TransportSettings transportSettings) => throw new NotImplementedException();
public void CustomizeMonitoringEndpoint(EndpointConfiguration endpointConfiguration,
TransportSettings transportSettings) => throw new NotImplementedException();
public void AddTransportForMonitoring(IServiceCollection services, TransportSettings transportSettings) => throw new NotImplementedException();
public Task ProvisionQueues(TransportSettings transportSettings, IEnumerable<string> additionalQueues)
{
QueuesCreated =
[
.. additionalQueues,
transportSettings.EndpointName,
transportSettings.ErrorQueue
];
return Task.CompletedTask;
}
public Task<TransportInfrastructure> CreateTransportInfrastructure(string name, TransportSettings transportSettings,
OnMessage onMessage = null, OnError onError = null, Func<string, Exception, Task> onCriticalError = null,
TransportTransactionMode preferredTransactionMode = TransportTransactionMode.ReceiveOnly) =>
throw new NotImplementedException();
public string ToTransportQualifiedQueueName(string queueName) => queueName;
}
}