public static QueryConstantsBag CreateTestManagementQueries(string invariantName) { //This is probably the same for all the databases. const string DeleteAllDataTemplate = @"DELETE OrleansStatisticsTable; DELETE OrleansClientMetricsTable; DELETE OrleansSiloMetricsTable; DELETE OrleansRemindersTable; DELETE OrleansMembershipTable; DELETE OrleansMembershipVersionTable;"; var queryBag = new QueryConstantsBag(); queryBag.AddOrModifyQueryConstant(AdoNetInvariants.InvariantNameSqlServer, RelationalTestingConstants.DeleteAllDataKey, DeleteAllDataTemplate); switch(invariantName) { case(AdoNetInvariants.InvariantNameSqlServer): { return CreateSqlServerQueries(); } default: { break; } } return queryBag; }
private static QueryConstantsBag CreateSqlServerQueries() { var queryBag = new QueryConstantsBag(); queryBag.AddOrModifyQueryConstant(AdoNetInvariants.InvariantNameSqlServer, RelationalTestingConstants.DefaultConnectionStringKey, @"Data Source=(localdb)\MSSQLLocalDB;Database=Master;Integrated Security=True;Asynchronous Processing=True;Max Pool Size=200; MultipleActiveResultSets=True"); queryBag.AddOrModifyQueryConstant(AdoNetInvariants.InvariantNameSqlServer, RelationalTestingConstants.ExistsDatabaseKey, "SELECT CAST(COUNT(1) AS BIT) FROM sys.databases WHERE name = @databaseName"); queryBag.AddOrModifyQueryConstant(AdoNetInvariants.InvariantNameSqlServer, RelationalTestingConstants.CreateDatabaseKey, @"USE [Master]; DECLARE @fileName AS NVARCHAR(255) = CONVERT(NVARCHAR(255), SERVERPROPERTY('instancedefaultdatapath')) + N'{0}'; EXEC('CREATE DATABASE [{0}] ON PRIMARY ( NAME = [{0}], FILENAME =''' + @fileName + ''', SIZE = 5MB, MAXSIZE = 100MB, FILEGROWTH = 5MB )')"); queryBag.AddOrModifyQueryConstant(AdoNetInvariants.InvariantNameSqlServer, RelationalTestingConstants.DropDatabaseKey, @"USE [Master]; ALTER DATABASE [{0}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{0}];"); return queryBag; }