public void ShouldUpgradeFrom1ToLatest()
    {
        DatabaseTestSetup.SetupSqlServer(ConnectionStrings.SqlServer, schemaVersion: 1);
        using (var c = new SqlConnection(ConnectionStrings.SqlServer))
            c.Execute("INSERT INTO HangfireConfiguration.Configuration ([Key], Value) VALUES ('GoalWorkerCount', 52)");

        install();

        Assert.AreEqual(52, read().Single().GoalWorkerCount);
        Assert.AreEqual(HangfireConfigurationSchemaInstaller.SchemaVersion, version());
    }
Esempio n. 2
0
 public void Setup()
 {
     if (_isSqlServer)
     {
         DatabaseTestSetup.SetupSqlServer(ConnectionString);
     }
     else
     {
         DatabaseTestSetup.SetupPostgres(ConnectionString);
     }
 }
    public void ShouldUpgradeFrom2To3()
    {
        DatabaseTestSetup.SetupSqlServer(ConnectionStrings.SqlServer, schemaVersion: 2);
        Assert.AreEqual(2, version());
        using (var c = new SqlConnection(ConnectionStrings.SqlServer))
        {
            c.Execute(@"INSERT INTO HangfireConfiguration.Configuration (ConnectionString) VALUES (@ConnectionString)", new values());
            c.Execute(@"INSERT INTO HangfireConfiguration.Configuration (ConnectionString) VALUES (@ConnectionString)", new values());
        }

        install(3);

        Assert.AreEqual(DefaultConfigurationName.Name(), read().First().Name);
        Assert.AreEqual(3, version());
    }
    public void ShouldUpgradeFrom2ToLatest()
    {
        DatabaseTestSetup.SetupSqlServer(ConnectionStrings.SqlServer, schemaVersion: 2);
        Assert.AreEqual(2, version());
        using (var c = new SqlConnection(ConnectionStrings.SqlServer))
            c.Execute(@"
INSERT INTO 
    HangfireConfiguration.Configuration 
    (ConnectionString, SchemaName, GoalWorkerCount, Active) 
    VALUES (@ConnectionString, @SchemaName, @GoalWorkerCount, @Active)
", new values {
                GoalWorkerCount = 99
            });

        install();

        Assert.AreEqual(99, read().Single().GoalWorkerCount);
        Assert.AreEqual(HangfireConfigurationSchemaInstaller.SchemaVersion, version());
    }
    public void ShouldInstallSchemaVersion3()
    {
        DatabaseTestSetup.SetupSqlServer(ConnectionStrings.SqlServer, schemaVersion: 3);

        Assert.AreEqual(3, version());
    }