Beispiel #1
0
        private static void AddAppConfig(string targetDir)
        {
            var configurationFile = Path.Combine(targetDir, "App.config");

            File.WriteAllText(
                configurationFile,
                @"<?xml version='1.0' encoding='utf-8' ?>
<configuration>
  <connectionStrings>
    <add name='ClassLibrary1' connectionString='" +
                DatabaseProviderFixture.InitializeTestDatabase(DatabaseProvider.SqlClient, DatabaseProviderFixture.DefaultDatabaseName).
                ConnectionString +
                @"' providerName='System.Data.SqlClient' />
  </connectionStrings>
</configuration>");
        }
Beispiel #2
0
 public DbMigratorTests(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
 public ScriptingScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #4
0
 public UpgradeScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #5
0
 public AddForeignKeyScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
 public ModificationFunctionsScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #7
0
 public CrossDatabaseScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #8
0
 public SpatialScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
 public DefaultValueScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
 public AlterTableAnnotationsScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #11
0
 public ExecuteStatements(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #12
0
 public DbMigratorTests_SqlClientOnly(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #13
0
 public DbMigratorTests_DatabaseInitialization(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #14
0
 public DbMigratorTests_ContextConstruction(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #15
0
 public BasicMigrationScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
 public DbPermissionsScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #17
0
 public LoggingScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
 public AddPrimaryKeyScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #19
0
        public ToolingFixture()
        {
            var          targetDir      = IOHelpers.GetTempDirName();
            const string targetName     = "ClassLibrary1";
            const string targetFileName = targetName + ".dll";
            var          targetPath     = Path.Combine(targetDir, targetFileName);

            var entityFrameworkPath = new Uri(typeof(DbContext).Assembly.CodeBase).LocalPath;

            IOHelpers.CopyToDir(entityFrameworkPath, targetDir);

            var entityFrameworkSqlServerPath = new Uri(typeof(SqlProviderServices).Assembly.CodeBase).LocalPath;

            IOHelpers.CopyToDir(entityFrameworkSqlServerPath, targetDir);

            using (var compiler = new CSharpCodeProvider())
            {
                var results
                    = compiler.CompileAssemblyFromSource(
                          new CompilerParameters(
                              new[]
                {
                    "System.dll",
                    "System.Data.dll",
                    "System.Core.dll",
                    "System.Data.Entity.dll",
                    entityFrameworkPath
                },
                              targetPath),
                          @"namespace ClassLibrary1
{
    using System.Data.Common;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Data.Entity.Migrations.History;

    public class Configuration : DbMigrationsConfiguration<Context>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
        }
    }

    public class Context : DbContext
    {
        public Context()
            : base(""Name=ClassLibrary1"")
        {
        }

        public DbSet<Entity> Entities { get; set; }
    }

    public class CustomHistoryContext : HistoryContext
    {
        public CustomHistoryContext(DbConnection existingConnection, bool contextOwnsConnection, string defaultSchema)
            : base(existingConnection, contextOwnsConnection, defaultSchema)
        {
        }
    }

    public class Entity
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}");

                if (results.Errors.HasErrors)
                {
                    throw new InvalidOperationException(results.Errors.Cast <CompilerError>().First(e => !e.IsWarning).ToString());
                }
            }

            var configurationFile = Path.Combine(targetDir, "App.config");

            File.WriteAllText(
                configurationFile,
                @"<?xml version='1.0' encoding='utf-8' ?>
<configuration>
  <connectionStrings>
    <add name='ClassLibrary1' connectionString='" +
                DatabaseProviderFixture.InitializeTestDatabase(DatabaseProvider.SqlClient, DatabaseProviderFixture.DefaultDatabaseName).
                ConnectionString +
                @"' providerName='System.Data.SqlClient' />
  </connectionStrings>
</configuration>");

            ProjectDir = targetDir;
        }
 public SqlClientTransactionScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
 public MultiTenantScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #22
0
 public SchemaScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
 public CreateIndexScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
 public DropColumnScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #25
0
 public CustomSqlScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #26
0
 public ToolingScenarios(DatabaseProviderFixture databaseProviderFixture, ToolingFixture data)
     : base(databaseProviderFixture)
 {
     _projectDir = data.ProjectDir;
     _contextDir = data.ContextDir;
 }
 public AutoAndGenerateTestCase(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
Beispiel #28
0
 public CreateTableScenarios(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }
 public DbSetMigrationsExtensionsTests(DatabaseProviderFixture databaseProviderFixture)
     : base(databaseProviderFixture)
 {
 }