From 14889fe6eb572b7048fc9a1a32c3b67c6f3ee8a0 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Thu, 26 Mar 2015 17:06:30 -0700 Subject: [PATCH] Adding a trait for tests and some general refactoring --- test/E2ETests/Common/DbUtils.cs | 4 +++- test/E2ETests/NtlmAuthentationTest.cs | 6 +++--- test/E2ETests/OpenIdConnectTests.cs | 8 ++++---- test/E2ETests/PublishAndRunTests.cs | 10 +++++----- test/E2ETests/SmokeTests.cs | 18 ++++++++---------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/E2ETests/Common/DbUtils.cs b/test/E2ETests/Common/DbUtils.cs index b3d509a203..e9d10ccf1e 100644 --- a/test/E2ETests/Common/DbUtils.cs +++ b/test/E2ETests/Common/DbUtils.cs @@ -9,12 +9,14 @@ namespace E2ETests /// 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) { try { 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(); diff --git a/test/E2ETests/NtlmAuthentationTest.cs b/test/E2ETests/NtlmAuthentationTest.cs index 4956d542ae..6429e493ba 100644 --- a/test/E2ETests/NtlmAuthentationTest.cs +++ b/test/E2ETests/NtlmAuthentationTest.cs @@ -10,7 +10,7 @@ namespace E2ETests { public partial class SmokeTests { - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [OSSkipCondition(OperatingSystems.Unix | OperatingSystems.MacOSX)] [InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, "http://localhost:5001/")] [InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.amd64, "http://localhost:5001/")] @@ -35,10 +35,10 @@ namespace E2ETests var stopwatch = Stopwatch.StartNew(); 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 - Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); + Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName)); _applicationBaseUrl = applicationBaseUrl; Process hostProcess = null; diff --git a/test/E2ETests/OpenIdConnectTests.cs b/test/E2ETests/OpenIdConnectTests.cs index d1af5a1a97..624dab87ee 100644 --- a/test/E2ETests/OpenIdConnectTests.cs +++ b/test/E2ETests/OpenIdConnectTests.cs @@ -9,7 +9,7 @@ namespace E2ETests { public partial class SmokeTests { - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/")] public void OpenIdConnect_OnX86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) @@ -17,7 +17,7 @@ namespace E2ETests OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); } - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.DotNet)] [InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/")] public void OpenIdConnect_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) @@ -43,10 +43,10 @@ namespace E2ETests var stopwatch = Stopwatch.StartNew(); 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 - Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); + Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName)); _applicationBaseUrl = applicationBaseUrl; Process hostProcess = null; diff --git a/test/E2ETests/PublishAndRunTests.cs b/test/E2ETests/PublishAndRunTests.cs index 51c63e9a6c..b83c0d43b4 100644 --- a/test/E2ETests/PublishAndRunTests.cs +++ b/test/E2ETests/PublishAndRunTests.cs @@ -10,7 +10,7 @@ namespace E2ETests { public partial class SmokeTests { - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/", false)] // [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); } - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.DotNet)] [InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/", false)] [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); } - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData(ServerType.WebListener, RuntimeFlavor.DesktopClr, RuntimeArchitecture.amd64, "http://localhost:5002/", false)] //https://github.com/aspnet/KRuntime/issues/642 @@ -57,10 +57,10 @@ namespace E2ETests var stopwatch = Stopwatch.StartNew(); 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 - Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); + Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName)); _applicationBaseUrl = applicationBaseUrl; Process hostProcess = null; diff --git a/test/E2ETests/SmokeTests.cs b/test/E2ETests/SmokeTests.cs index c1b28d2307..c3bd7acb0f 100644 --- a/test/E2ETests/SmokeTests.cs +++ b/test/E2ETests/SmokeTests.cs @@ -9,8 +9,6 @@ namespace E2ETests { public partial class SmokeTests { - private const string CONNECTION_STRING_FORMAT = "Server=(localdb)\\MSSQLLocalDB;Database={0};Trusted_Connection=True;MultipleActiveResultSets=true"; - private string _applicationBaseUrl; private HttpClient _httpClient; private HttpClientHandler _httpClientHandler; @@ -24,7 +22,7 @@ namespace E2ETests _logger = loggerFactory.CreateLogger(); } - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData(ServerType.IISExpress, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5001/")] [InlineData(ServerType.WebListener, RuntimeFlavor.DesktopClr, RuntimeArchitecture.x86, "http://localhost:5002/")] @@ -37,7 +35,7 @@ namespace E2ETests SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); } - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [SkipOn32BitOS] [InlineData(ServerType.WebListener, RuntimeFlavor.DesktopClr, RuntimeArchitecture.amd64, "http://localhost:5002/")] @@ -48,7 +46,7 @@ namespace E2ETests SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl); } - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.DotNet)] [InlineData(ServerType.Kestrel, RuntimeFlavor.Mono, RuntimeArchitecture.x86, "http://localhost:5004/")] public void SmokeTestSuite_OnMono(ServerType serverType, RuntimeFlavor donetFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) @@ -56,7 +54,7 @@ namespace E2ETests SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl); } - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [SkipIfNativeModuleNotInstalled] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)] @@ -67,7 +65,7 @@ namespace E2ETests SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl); } - [ConditionalTheory] + [ConditionalTheory, Trait("E2Etests", "E2Etests")] [SkipIfNativeModuleNotInstalled] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)] @@ -79,7 +77,7 @@ namespace E2ETests SmokeTestSuite(serverType, donetFlavor, architecture, applicationBaseUrl); } - // [ConditionalTheory] + // [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Unix)] [SkipIfCurrentRuntimeIsCoreClr] @@ -107,10 +105,10 @@ namespace E2ETests var stopwatch = Stopwatch.StartNew(); 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 - Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName)); + Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName)); _applicationBaseUrl = applicationBaseUrl; Process hostProcess = null;