-
Notifications
You must be signed in to change notification settings - Fork 1
/
connectionString.patch
57 lines (52 loc) · 2.92 KB
/
connectionString.patch
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
diff --git a/source/Messaging.IntegrationTests/Fixtures/DatabaseFixture.cs b/source/Messaging.IntegrationTests/Fixtures/DatabaseFixture.cs
index c88b5dfc..261c887d 100644
--- a/source/Messaging.IntegrationTests/Fixtures/DatabaseFixture.cs
+++ b/source/Messaging.IntegrationTests/Fixtures/DatabaseFixture.cs
@@ -26,19 +26,26 @@ namespace Messaging.IntegrationTests.Fixtures
{
public class DatabaseFixture : IDisposable, IAsyncLifetime
{
+ private static string _connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=B2BTransactions;Integrated Security=True;Connection Timeout=60";
private readonly B2BContext _context;
private bool _disposed;
public DatabaseFixture()
{
+ var environmentVariableConnectionString = Environment.GetEnvironmentVariable("B2B_MESSAGING_CONNECTION_STRING");
+ if (!string.IsNullOrWhiteSpace(environmentVariableConnectionString))
+ {
+ _connectionString = environmentVariableConnectionString;
+ }
+
var optionsBuilder = new DbContextOptionsBuilder<B2BContext>();
optionsBuilder
- .UseSqlServer(ConnectionString, options => options.UseNodaTime());
+ .UseSqlServer(_connectionString, options => options.UseNodaTime());
_context = new B2BContext(optionsBuilder.Options, new Serializer());
}
- public string ConnectionString { get; } = @"Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=B2BTransactions;Integrated Security=True;Connection Timeout=60";
+ public static string ConnectionString => _connectionString;
public Task InitializeAsync()
{
@@ -89,7 +96,7 @@ namespace Messaging.IntegrationTests.Fixtures
_disposed = true;
}
- private void CreateSchema()
+ private static void CreateSchema()
{
DefaultUpgrader.Upgrade(ConnectionString);
}
diff --git a/source/Messaging.IntegrationTests/TestBase.cs b/source/Messaging.IntegrationTests/TestBase.cs
index 4251687f..ba814701 100644
--- a/source/Messaging.IntegrationTests/TestBase.cs
+++ b/source/Messaging.IntegrationTests/TestBase.cs
@@ -58,8 +58,8 @@ namespace Messaging.IntegrationTests
CompositionRoot.Initialize(_services)
.AddPeekConfiguration(new BundleConfigurationStub())
.AddRemoteBusinessService<DummyRequest, DummyReply>(sp => new RemoteBusinessServiceRequestSenderSpy<DummyRequest>("Dummy"), "Dummy")
- .AddDatabaseConnectionFactory(_databaseFixture.ConnectionString)
- .AddDatabaseContext(_databaseFixture.ConnectionString)
+ .AddDatabaseConnectionFactory(DatabaseFixture.ConnectionString)
+ .AddDatabaseContext(DatabaseFixture.ConnectionString)
.AddSystemClock(new SystemDateTimeProviderStub())
.AddCorrelationContext(_ =>
{