Пример #1
0
 private static Guid CreateDatabase()
 {
     var database = Guid.NewGuid();
     var connectionString = string.Format("Data Source=localhost;Integrated Security=true;");
     var factory = new SqlServerConnectionFactory { ConnectionString = connectionString };
     using (var connection = factory.CreateConnection())
     {
         connection.Open();
         var sql = string.Format("CREATE DATABASE [{0}]", database);
         connection.Execute(sql);
     }
     return database;
 }
Пример #2
0
        private string ConfigureTestDatabase()
        {
            var database = CreateDatabase();
            var connectionString = string.Format("Data Source=localhost;Initial Catalog={0};Integrated Security=true", database);
            tophat.Database.Install<SqlServerConnectionFactory>(connectionString, ConnectionScope.ByThread);
            Database = database.ToString();

            var factory = new SqlServerConnectionFactory { ConnectionString = connectionString };
            using (var connection = factory.CreateConnection())
            {
                connection.Open();
                Schema.Install(DatabaseDialect.SqlServer, connection);
            }

            return connectionString;
        }