mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
This reverts commit 1c621da4c7.
This commit is contained in:
26
extensions/dacpac/src/controllers/controllerBase.ts
Normal file
26
extensions/dacpac/src/controllers/controllerBase.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
export default abstract class ControllerBase implements vscode.Disposable {
|
||||||
|
protected _context: vscode.ExtensionContext;
|
||||||
|
|
||||||
|
protected constructor(context: vscode.ExtensionContext) {
|
||||||
|
this._context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get extensionContext(): vscode.ExtensionContext {
|
||||||
|
return this._context;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract activate(): Promise<boolean>;
|
||||||
|
|
||||||
|
abstract deactivate(): void;
|
||||||
|
|
||||||
|
public dispose(): void {
|
||||||
|
this.deactivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,17 +4,20 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
|
import ControllerBase from './controllerBase';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { DataTierApplicationWizard } from '../wizard/dataTierApplicationWizard';
|
import { DataTierApplicationWizard } from '../wizard/dataTierApplicationWizard';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main controller class that initializes the extension
|
* The main controller class that initializes the extension
|
||||||
*/
|
*/
|
||||||
export default class MainController implements vscode.Disposable {
|
export default class MainController extends ControllerBase {
|
||||||
|
|
||||||
public constructor(private context: vscode.ExtensionContext) {
|
public constructor(context: vscode.ExtensionContext) {
|
||||||
|
super(context);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*/
|
||||||
public deactivate(): void {
|
public deactivate(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,12 +29,4 @@ export default class MainController implements vscode.Disposable {
|
|||||||
private initializeDacFxWizard() {
|
private initializeDacFxWizard() {
|
||||||
azdata.tasks.registerTask('dacFx.start', (profile: azdata.IConnectionProfile, ...args: any[]) => new DataTierApplicationWizard().start(profile, args));
|
azdata.tasks.registerTask('dacFx.start', (profile: azdata.IConnectionProfile, ...args: any[]) => new DataTierApplicationWizard().start(profile, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
public get extensionContext(): vscode.ExtensionContext {
|
|
||||||
return this.context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public dispose(): void {
|
|
||||||
this.deactivate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
import ControllerBase from './controllers/controllerBase';
|
||||||
import MainController from './controllers/mainController';
|
import MainController from './controllers/mainController';
|
||||||
|
|
||||||
let controllers: MainController[] = [];
|
let controllers: ControllerBase[] = [];
|
||||||
|
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
let activations: Promise<boolean>[] = [];
|
let activations: Promise<boolean>[] = [];
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------------------------
|
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
||||||
*--------------------------------------------------------------------------------------------*/
|
|
||||||
import * as should from 'should';
|
|
||||||
import MainController from '../controllers/mainController';
|
|
||||||
import { TestContext, createContext } from './testContext';
|
|
||||||
|
|
||||||
let testContext: TestContext;
|
|
||||||
|
|
||||||
function createController(): MainController {
|
|
||||||
let controller = new MainController(testContext.context);
|
|
||||||
return controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('MainController', function (): void {
|
|
||||||
before(async function (): Promise<void> {
|
|
||||||
testContext = createContext();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Should create new instance successfully', async function (): Promise<void> {
|
|
||||||
let controller: MainController;
|
|
||||||
should.doesNotThrow(() => controller = createController());
|
|
||||||
should.notEqual(controller.extensionContext, undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------------------------
|
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
||||||
*--------------------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
import * as vscode from 'vscode';
|
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
export interface TestContext {
|
|
||||||
context: vscode.ExtensionContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createContext(): TestContext {
|
|
||||||
let extensionPath = path.join(__dirname, '..', '..');
|
|
||||||
|
|
||||||
return {
|
|
||||||
context: {
|
|
||||||
subscriptions: [],
|
|
||||||
workspaceState: {
|
|
||||||
get: () => { return Promise.resolve(); },
|
|
||||||
update: () => { return Promise.resolve(); }
|
|
||||||
},
|
|
||||||
globalState: {
|
|
||||||
get: () => { return Promise.resolve(); },
|
|
||||||
update: () => { return Promise.resolve(); }
|
|
||||||
},
|
|
||||||
extensionPath: extensionPath,
|
|
||||||
asAbsolutePath: () => { return ''; },
|
|
||||||
storagePath: '',
|
|
||||||
globalStoragePath: '',
|
|
||||||
logPath: '',
|
|
||||||
extensionUri: vscode.Uri.parse('')
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -7,16 +7,10 @@ import 'mocha';
|
|||||||
import * as should from 'should';
|
import * as should from 'should';
|
||||||
import * as loc from '../localizedConstants';
|
import * as loc from '../localizedConstants';
|
||||||
import { DataTierApplicationWizard, Operation } from '../wizard/dataTierApplicationWizard';
|
import { DataTierApplicationWizard, Operation } from '../wizard/dataTierApplicationWizard';
|
||||||
import { DacFxDataModel } from '../wizard/api/models';
|
|
||||||
|
|
||||||
let wizard: DataTierApplicationWizard;
|
|
||||||
describe('Dacfx wizard', function (): void {
|
describe('Dacfx wizard', function (): void {
|
||||||
beforeEach(async function (): Promise<void> {
|
|
||||||
wizard = new DataTierApplicationWizard();
|
|
||||||
wizard.model = <DacFxDataModel>{};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Should initialize wizard correctly', async () => {
|
it('Should initialize wizard correctly', async () => {
|
||||||
|
let wizard = new DataTierApplicationWizard();
|
||||||
should.notEqual(wizard.wizard, undefined);
|
should.notEqual(wizard.wizard, undefined);
|
||||||
should.equal(wizard.wizard.title, loc.wizardTitle);
|
should.equal(wizard.wizard.title, loc.wizardTitle);
|
||||||
|
|
||||||
@@ -24,50 +18,8 @@ describe('Dacfx wizard', function (): void {
|
|||||||
should.notEqual(wizard.pages, undefined);
|
should.notEqual(wizard.pages, undefined);
|
||||||
should.equal(wizard.pages.size, 7);
|
should.equal(wizard.pages.size, 7);
|
||||||
should.equal(wizard.wizard.pages.length, 4);
|
should.equal(wizard.wizard.pages.length, 4);
|
||||||
});
|
|
||||||
|
|
||||||
it('Should determine summary page correctly', async () => {
|
|
||||||
// summary page should be 2 for deploy
|
|
||||||
wizard.selectedOperation = Operation.deploy;
|
|
||||||
wizard.model.upgradeExisting = false;
|
|
||||||
should.equal(wizard.isSummaryPage(2), true);
|
|
||||||
|
|
||||||
// summary page should be 3 for deploy - upgrade existing db
|
|
||||||
wizard.selectedOperation = Operation.deploy;
|
|
||||||
wizard.model.upgradeExisting = true;
|
|
||||||
should.equal(wizard.isSummaryPage(3), true);
|
|
||||||
|
|
||||||
// summary page should be 3 for generate deploy script
|
|
||||||
wizard.selectedOperation = Operation.generateDeployScript;
|
|
||||||
should.equal(wizard.isSummaryPage(3), true);
|
|
||||||
|
|
||||||
// summary page should be 2 for import
|
|
||||||
wizard.selectedOperation = Operation.import;
|
|
||||||
should.equal(wizard.isSummaryPage(2), true);
|
|
||||||
|
|
||||||
// summary page should be 2 for export
|
|
||||||
wizard.selectedOperation = Operation.export;
|
|
||||||
should.equal(wizard.isSummaryPage(2), true);
|
|
||||||
|
|
||||||
// summary page should be 2 for extract
|
|
||||||
wizard.selectedOperation = Operation.extract;
|
|
||||||
should.equal(wizard.isSummaryPage(2), true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Should set Done button and operation correctly', async () => {
|
|
||||||
wizard.setDoneButton(Operation.deploy);
|
wizard.setDoneButton(Operation.deploy);
|
||||||
should.equal(wizard.selectedOperation, Operation.deploy);
|
should.equal(wizard.selectedOperation, Operation.deploy);
|
||||||
|
|
||||||
wizard.setDoneButton(Operation.generateDeployScript);
|
|
||||||
should.equal(wizard.selectedOperation, Operation.generateDeployScript);
|
|
||||||
|
|
||||||
wizard.setDoneButton(Operation.extract);
|
|
||||||
should.equal(wizard.selectedOperation, Operation.extract);
|
|
||||||
|
|
||||||
wizard.setDoneButton(Operation.import);
|
|
||||||
should.equal(wizard.selectedOperation, Operation.import);
|
|
||||||
|
|
||||||
wizard.setDoneButton(Operation.export);
|
|
||||||
should.equal(wizard.selectedOperation, Operation.export);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export enum PageName {
|
|||||||
export class DataTierApplicationWizard {
|
export class DataTierApplicationWizard {
|
||||||
public wizard: azdata.window.Wizard;
|
public wizard: azdata.window.Wizard;
|
||||||
private connection: azdata.connection.ConnectionProfile;
|
private connection: azdata.connection.ConnectionProfile;
|
||||||
public model: DacFxDataModel;
|
private model: DacFxDataModel;
|
||||||
public pages: Map<string, Page> = new Map<string, Page>();
|
public pages: Map<string, Page> = new Map<string, Page>();
|
||||||
public selectedOperation: Operation;
|
public selectedOperation: Operation;
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ export class DataTierApplicationWizard {
|
|||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public isSummaryPage(idx: number): boolean {
|
private isSummaryPage(idx: number): boolean {
|
||||||
return this.selectedOperation === Operation.import && idx === ImportOperationPath.summary
|
return this.selectedOperation === Operation.import && idx === ImportOperationPath.summary
|
||||||
|| this.selectedOperation === Operation.export && idx === ExportOperationPath.summary
|
|| this.selectedOperation === Operation.export && idx === ExportOperationPath.summary
|
||||||
|| this.selectedOperation === Operation.extract && idx === ExtractOperationPath.summary
|
|| this.selectedOperation === Operation.extract && idx === ExtractOperationPath.summary
|
||||||
|
|||||||
Reference in New Issue
Block a user