Skip to content

Commit d33bdcb

Browse files
authored
Merge pull request #53 from mjohanss/master
Fixing issue with applicationhost.config not being re-generated at bu…
2 parents ed21853 + e6ba5fe commit d33bdcb

File tree

7 files changed

+18
-1057
lines changed

7 files changed

+18
-1057
lines changed

src/Server/Coderr.Server.SqlServer.Tests/Helpers/DatabaseManager.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class DatabaseManager : IDisposable
2222
public DatabaseManager(string databaseName = null)
2323
{
2424
var instanceId = Interlocked.Increment(ref InstanceCounter);
25-
_databaseName = databaseName ?? $"coderTest{DateTime.Now:MMddHHmmss}_{instanceId}";
25+
_databaseName = databaseName ?? $"coderrTest{DateTime.Now:MMddHHmmss}_{instanceId}";
2626
Console.WriteLine("DBNMAE: " + _databaseName);
2727
ConnectionString = ConnectionStringHelper.GetConnectionString().ConnectionString
2828
.Replace("{databaseName}", _databaseName);
@@ -46,8 +46,6 @@ public void Dispose()
4646
public void CreateEmptyDatabase()
4747
{
4848
Debug.WriteLine("*****DBNAME: " + ConnectionString);
49-
var builder = new SqlConnectionStringBuilder(ConnectionString);
50-
Environment.SetEnvironmentVariable("coderr_ConnectionString", $"Data Source={builder.DataSource}");
5149

5250
using (var con = OpenConnection(_masterConString))
5351
{

src/Server/Coderr.Server.SqlServer.Tests/Helpers/TestDataManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public void ActivateAccount(int accountId)
6666
}
6767
}
6868

69-
7069
/// <summary>
7170
/// Creates an incident and a report.
7271
/// </summary>

src/Server/Coderr.Server.SqlServer.Tests/IntegrationTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using codeRR.Server.Api.Core.Incidents.Queries;
32
using codeRR.Server.SqlServer.Core.Accounts;
43
using codeRR.Server.SqlServer.Tests.Helpers;
54
using Griffin.Data;

src/Server/Coderr.Server.Web.Tests/Helpers/IisExpressHelper.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ public void Start(string site)
6060
SetDefaultsWhereNecessary();
6161

6262
if (!File.Exists(ExePath))
63-
throw new FileNotFoundException("Path to IIS Express executable is invalid: '" + ExePath + "'.");
63+
throw new FileNotFoundException($"Path to IIS Express executable is invalid: '{ExePath}'.");
6464

6565
if (string.IsNullOrEmpty(ConfigPath) || !File.Exists(ConfigPath))
66-
throw new FileNotFoundException("Path to IIS Express configuration file is invalid: '" + ConfigPath +
67-
"'.");
66+
throw new FileNotFoundException($"Path to IIS Express configuration file is invalid: '{ConfigPath}'.");
6867

6968
var iisExpressThread = new Thread(() => StartIisExpress(p => _process = p, site)) {IsBackground = true};
7069
iisExpressThread.Start();
@@ -76,9 +75,9 @@ public void Start(string site)
7675
Thread.Sleep(200);
7776
attemptsLeft--;
7877
}
78+
7979
if (_process == null)
8080
throw new InvalidOperationException("Failed to start IIS express");
81-
8281
}
8382

8483
/// <summary>
@@ -155,7 +154,6 @@ private void StartIisExpress(Action<Process> action, string site)
155154
if (!isRunning)
156155
throw new InvalidOperationException("Failed to receive data from IIS ex");
157156

158-
159157
action(process);
160158
}
161159
}

src/Server/Coderr.Server.Web.Tests/WebTest.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ static WebTest()
2525
mapper.Scan(typeof(AccountRepository).Assembly);
2626
EntityMappingProvider.Provider = mapper;
2727

28-
2928
_databaseManager.CreateEmptyDatabase();
3029
_databaseManager.InitSchema();
3130

@@ -39,12 +38,12 @@ static WebTest()
3938
_iisExpress = new IisExpressHelper
4039
{
4140
ConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "applicationhost.config"),
42-
EnvironmentVariables =
43-
new Dictionary<string, string> { { "coderr_ConnectionString", _databaseManager.ConnectionString } }
41+
42+
// Pass on connectionstring to codeRR.Server.Web during testing, overriding connectionstring in web.config
43+
EnvironmentVariables = new Dictionary<string, string> { { "coderr_ConnectionString", _databaseManager.ConnectionString } }
4444
};
4545
_iisExpress.Start("codeRR.Server.Web");
4646

47-
4847
TestData = new TestDataManager(_databaseManager.OpenConnection);
4948
WebDriver = DriverFactory.Create(BrowserType.Chrome);
5049
AppDomain.CurrentDomain.DomainUnload += (o, e) => { DisposeWebDriver(); };
@@ -56,7 +55,6 @@ protected WebTest()
5655
TestData.ResetDatabase(_iisExpress.BaseUrl);
5756
}
5857

59-
6058
public string ServerUrl => _iisExpress.BaseUrl;
6159

6260
public static TestDataManager TestData { get; }

0 commit comments

Comments
 (0)