public void VersionControl() { var sectorDb = TestUtils.MakeSectorDb(); var repository = TestUtils.MakeRepository(); MigrateApi migrateApi = new MigrateApi(sectorDb); Assert.IsFalse(migrateApi.IsVersionControlled(repository)); migrateApi.VersionControl(repository); Assert.IsTrue(migrateApi.IsVersionControlled(repository)); Assert.AreEqual(0, migrateApi.GetDbVersion(repository)); using (var dbConn = TestUtils.OpenDbconnection()) using (var dbCommand = dbConn.CreateCommand()) { string templ = "SELECT * FROM {0} WHERE repository_id = '{1}'"; dbCommand.CommandText = string.Format(templ, SectorDb.TableName, repository.RepositoryId); var reader = dbCommand.ExecuteReader(); Assert.AreEqual(repository.RepositoryId, reader["repository_id"]); Assert.AreEqual(repository.RepositoryPath, reader["repository_path"]); Assert.AreEqual(0, reader["version"]); } // Trying again results in SectorException. Assert.Throws<SectorException>(delegate { migrateApi.VersionControl(repository); }); }
public void IsVersionControlled() { var sectorDb = TestUtils.MakeSectorDb(); var repository = TestUtils.MakeRepository(); // Need to start with the schema created. TestUtils.CreateMigrationTable(); var migrateApi = new MigrateApi(sectorDb); bool success = migrateApi.IsVersionControlled(repository); Assert.IsFalse(success); using (var dbConn = TestUtils.OpenDbconnection()) using (var dbCommand = dbConn.CreateCommand()) { string templ = "INSERT INTO migrate_version (repository_id, repository_path, version) VALUES('{0}', '{1}', '{2}')"; dbCommand.CommandText = string.Format(templ, repository.RepositoryId, repository.RepositoryPath, 0); dbCommand.ExecuteNonQuery(); } success = migrateApi.IsVersionControlled(repository); Assert.IsTrue(success); }