Adding a trait for tests and some general refactoring

This commit is contained in:
Praburaj 2015-03-26 17:06:30 -07:00
parent 1eb38e5708
commit 14889fe6eb
5 changed files with 23 additions and 23 deletions

View File

@ -9,12 +9,14 @@ namespace E2ETests
/// </summary> /// </summary>
public class DbUtils public class DbUtils
{ {
public const string CONNECTION_STRING_FORMAT = "Server=(localdb)\\MSSQLLocalDB;Database={0};Trusted_Connection=True;MultipleActiveResultSets=true";
public static void DropDatabase(string databaseName, ILogger logger) public static void DropDatabase(string databaseName, ILogger logger)
{ {
try try
{ {
logger.LogInformation("Trying to drop database '{0}'", databaseName); logger.LogInformation("Trying to drop database '{0}'", databaseName);
using (var conn = new SqlConnection(@"Server=(localdb)\MSSQLLocalDB;Database=master;Trusted_Connection=True;")) using (var conn = new SqlConnection(string.Format(CONNECTION_STRING_FORMAT, "master")))
{ {
conn.Open(); conn.Open();

View File

@ -10,7 +10,7 @@ namespace E2ETests
{ {
public partial class SmokeTests public partial class SmokeTests
{ {
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[OSSkipCondition(OperatingSystems.Unix | OperatingSystems.MacOSX)] [OSSkipCondition(OperatingSystems.Unix | OperatingSystems.MacOSX)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, "http://localhost:5001/")] [InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, "http://localhost:5001/")]
[InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.amd64, "http://localhost:5001/")] [InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.amd64, "http://localhost:5001/")]
@ -35,10 +35,10 @@ namespace E2ETests
var stopwatch = Stopwatch.StartNew(); var stopwatch = Stopwatch.StartNew();
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty); var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); _logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName));
//Override the connection strings using environment based configuration //Override the connection strings using environment based configuration
Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName));
_applicationBaseUrl = applicationBaseUrl; _applicationBaseUrl = applicationBaseUrl;
Process hostProcess = null; Process hostProcess = null;

View File

@ -9,7 +9,7 @@ namespace E2ETests
{ {
public partial class SmokeTests public partial class SmokeTests
{ {
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)] [FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/")] [InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/")]
public void OpenIdConnect_OnX86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) public void OpenIdConnect_OnX86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
@ -17,7 +17,7 @@ namespace E2ETests
OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl);
} }
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[FrameworkSkipCondition(RuntimeFrameworks.DotNet)] [FrameworkSkipCondition(RuntimeFrameworks.DotNet)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/")] [InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/")]
public void OpenIdConnect_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) public void OpenIdConnect_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
@ -43,10 +43,10 @@ namespace E2ETests
var stopwatch = Stopwatch.StartNew(); var stopwatch = Stopwatch.StartNew();
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty); var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); _logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName));
//Override the connection strings using environment based configuration //Override the connection strings using environment based configuration
Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName));
_applicationBaseUrl = applicationBaseUrl; _applicationBaseUrl = applicationBaseUrl;
Process hostProcess = null; Process hostProcess = null;

View File

@ -10,7 +10,7 @@ namespace E2ETests
{ {
public partial class SmokeTests public partial class SmokeTests
{ {
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)] [FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/", false)] [InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/", false)]
// [InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/", true)] // [InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/", true)]
@ -19,7 +19,7 @@ namespace E2ETests
Publish_And_Run_Tests(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource); Publish_And_Run_Tests(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource);
} }
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[FrameworkSkipCondition(RuntimeFrameworks.DotNet)] [FrameworkSkipCondition(RuntimeFrameworks.DotNet)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/", false)] [InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/", false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/", true)] [InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/", true)]
@ -28,7 +28,7 @@ namespace E2ETests
Publish_And_Run_Tests(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource); Publish_And_Run_Tests(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource);
} }
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)] [FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[InlineData(ServerType.WebListener, RuntimeFlavor.DesktopClr, RuntimeArchitecture.amd64, "http://localhost:5002/", false)] [InlineData(ServerType.WebListener, RuntimeFlavor.DesktopClr, RuntimeArchitecture.amd64, "http://localhost:5002/", false)]
//https://github.com/aspnet/KRuntime/issues/642 //https://github.com/aspnet/KRuntime/issues/642
@ -57,10 +57,10 @@ namespace E2ETests
var stopwatch = Stopwatch.StartNew(); var stopwatch = Stopwatch.StartNew();
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty); var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); _logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName));
//Override the connection strings using environment based configuration //Override the connection strings using environment based configuration
Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName));
_applicationBaseUrl = applicationBaseUrl; _applicationBaseUrl = applicationBaseUrl;
Process hostProcess = null; Process hostProcess = null;

View File

@ -9,8 +9,6 @@ namespace E2ETests
{ {
public partial class SmokeTests public partial class SmokeTests
{ {
private const string CONNECTION_STRING_FORMAT = "Server=(localdb)\\MSSQLLocalDB;Database={0};Trusted_Connection=True;MultipleActiveResultSets=true";
private string _applicationBaseUrl; private string _applicationBaseUrl;
private HttpClient _httpClient; private HttpClient _httpClient;
private HttpClientHandler _httpClientHandler; private HttpClientHandler _httpClientHandler;
@ -24,7 +22,7 @@ namespace E2ETests
_logger = loggerFactory.CreateLogger<SmokeTests>(); _logger = loggerFactory.CreateLogger<SmokeTests>();
} }
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)] [FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/")] [InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/")]
[InlineData(ServerType.WebListener, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5002/")] [InlineData(ServerType.WebListener, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5002/")]
@ -37,7 +35,7 @@ namespace E2ETests
SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl);
} }
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)] [FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[SkipOn32BitOS] [SkipOn32BitOS]
[InlineData(ServerType.WebListener, RuntimeFlavor.DesktopClr, RuntimeArchitecture.amd64, "http://localhost:5002/")] [InlineData(ServerType.WebListener, RuntimeFlavor.DesktopClr, RuntimeArchitecture.amd64, "http://localhost:5002/")]
@ -48,7 +46,7 @@ namespace E2ETests
SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl); SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl);
} }
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[FrameworkSkipCondition(RuntimeFrameworks.DotNet)] [FrameworkSkipCondition(RuntimeFrameworks.DotNet)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/")] [InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/")]
public void SmokeTestSuite_OnMono(ServerType serverType, RuntimeFlavor donetFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) public void SmokeTestSuite_OnMono(ServerType serverType, RuntimeFlavor donetFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
@ -56,7 +54,7 @@ namespace E2ETests
SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl); SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl);
} }
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[SkipIfNativeModuleNotInstalled] [SkipIfNativeModuleNotInstalled]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)] [FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)] [OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)]
@ -67,7 +65,7 @@ namespace E2ETests
SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl); SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl);
} }
[ConditionalTheory] [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[SkipIfNativeModuleNotInstalled] [SkipIfNativeModuleNotInstalled]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)] [FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)] [OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)]
@ -79,7 +77,7 @@ namespace E2ETests
SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl); SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl);
} }
// [ConditionalTheory] // [ConditionalTheory, Trait("E2Etests", "E2Etests")]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)] [FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Unix)] [OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Unix)]
[SkipIfCurrentRuntimeIsCoreClr] [SkipIfCurrentRuntimeIsCoreClr]
@ -107,10 +105,10 @@ namespace E2ETests
var stopwatch = Stopwatch.StartNew(); var stopwatch = Stopwatch.StartNew();
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty); var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); _logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName));
//Override the connection strings using environment based configuration //Override the connection strings using environment based configuration
Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName));
_applicationBaseUrl = applicationBaseUrl; _applicationBaseUrl = applicationBaseUrl;
Process hostProcess = null; Process hostProcess = null;