Skip to content

Commit 0f708d6

Browse files
committed
Fixing issue with applicationhost.config not being re-generated at build by automatically generating any t4 template in codeRR.Server.Web.Tests upon build. Refactoring and some cleanup of integration/ui tests.
1 parent 5778e3c commit 0f708d6

File tree

7 files changed

+24
-1057
lines changed

7 files changed

+24
-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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using codeRR.Server.SqlServer.Core.Accounts;
45
using codeRR.Server.SqlServer.Tests.Helpers;
56
using codeRR.Server.Web.Tests.Helpers;
67
using codeRR.Server.Web.Tests.Helpers.Selenium;
78
using codeRR.Server.Web.Tests.Helpers.xUnit;
9+
using Griffin.Data.Mapper;
810
using OpenQA.Selenium;
911
using OpenQA.Selenium.Support.Extensions;
1012
using Xunit;
@@ -21,6 +23,10 @@ public abstract class WebTest
2123

2224
static WebTest()
2325
{
26+
var mapper = new AssemblyScanningMappingProvider();
27+
mapper.Scan(typeof(AccountRepository).Assembly);
28+
EntityMappingProvider.Provider = mapper;
29+
2430
_databaseManager.CreateEmptyDatabase();
2531
_databaseManager.InitSchema();
2632

@@ -35,12 +41,12 @@ static WebTest()
3541
_iisExpress = new IisExpressHelper
3642
{
3743
ConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "applicationhost.config"),
38-
EnvironmentVariables =
39-
new Dictionary<string, string> { { "coderr_ConnectionString", _databaseManager.ConnectionString } }
44+
45+
// Pass on connectionstring to codeRR.Server.Web during testing, overriding connectionstring in web.config
46+
EnvironmentVariables = new Dictionary<string, string> { { "coderr_ConnectionString", _databaseManager.ConnectionString } }
4047
};
4148
_iisExpress.Start("codeRR.Server.Web");
4249

43-
4450
TestData = new TestDataManager(_databaseManager.OpenConnection);
4551
}
4652

@@ -52,14 +58,12 @@ protected WebTest()
5258
TestData.ResetDatabase(_iisExpress.BaseUrl);
5359
}
5460

55-
5661
public string ServerUrl => _iisExpress.BaseUrl;
5762

5863
public static TestDataManager TestData { get; }
5964

6065
public IWebDriver WebDriver { get; private set; }
6166

62-
6367
public void Dispose()
6468
{
6569
if (_disposed)

0 commit comments

Comments
 (0)