* Enable noUnusedLocals

* remove one more

* More fixes
This commit is contained in:
Charles Gagnon 2021-08-05 16:40:03 -07:00 коммит произвёл GitHub
Родитель d13b65c24d
Коммит bfadadb028
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
32 изменённых файлов: 354 добавлений и 454 удалений

Просмотреть файл

@ -8,16 +8,14 @@ import { IAccount, IAccountKey } from '../models/contracts/azure/accountInterfac
import SqlToolsServiceClient from '../languageservice/serviceclient';
import { IAzureSession } from '../models/interfaces';
import * as Constants from '../constants/constants';
import VscodeWrapper from '../controllers/vscodeWrapper';
import { AzureController } from './azureController';
import { AccountStore } from './accountStore';
import providerSettings from '../azure/providerSettings';
import { Tenant, Token } from 'ads-adal-library';
import { Tenant } from 'ads-adal-library';
export class AccountService {
private _account: IAccount = undefined;
private _token = undefined;
private _isStale: boolean;
protected readonly commonTenant: Tenant = {
id: 'common',
@ -26,7 +24,6 @@ export class AccountService {
constructor(
private _client: SqlToolsServiceClient,
private _vscodeWrapper: VscodeWrapper,
private _context: vscode.ExtensionContext,
private _accountStore: AccountStore
) {}
@ -43,13 +40,6 @@ export class AccountService {
return this._client;
}
/**
* Public for testing purposes only
*/
public set token(value: any) {
this._token = value;
}
public convertToAzureAccount(azureSession: IAzureSession): IAccount {
let tenant = {
displayName: Constants.tenantDisplayName,

Просмотреть файл

@ -129,7 +129,7 @@ export class AzureAuthRequest implements AuthRequest {
const selection = await this._vscodeWrapper.showInformationMessage(msg, LocalizedConstants.msgCopyAndOpenWebpage);
if (selection === LocalizedConstants.msgCopyAndOpenWebpage) {
this._vscodeWrapper.clipboardWriteText(userCode);
let test = await vscode.env.openExternal(vscode.Uri.parse(verificationUrl));
await vscode.env.openExternal(vscode.Uri.parse(verificationUrl));
console.log(msg);
console.log(userCode);
console.log(verificationUrl);

Просмотреть файл

@ -14,7 +14,7 @@ import { CredentialStore } from '../credentialstore/credentialstore';
import { StorageService } from './StorageService';
import * as utils from '../models/utils';
import { IAccount } from '../models/contracts/azure/accountInterfaces';
import { AADResource, AzureAuthType, AzureCodeGrant, AzureDeviceCode, ProviderSettings, Token } from 'ads-adal-library';
import { AADResource, AzureAuthType, AzureCodeGrant, AzureDeviceCode, Token } from 'ads-adal-library';
import { ConnectionProfile } from '../models/connectionProfile';
import { AccountStore } from './accountStore';
import providerSettings from '../azure/providerSettings';

Просмотреть файл

@ -126,7 +126,7 @@ export default class ConnectionManager {
}
// Initiate the firewall service
this._accountService = new AccountService(this.client, this.vscodeWrapper, context, this._accountStore);
this._accountService = new AccountService(this.client, context, this._accountStore);
this._firewallService = new FirewallService(this._accountService);
this._failedUriToFirewallIpMap = new Map<string, string>();
@ -274,15 +274,6 @@ export default class ConnectionManager {
// Using a lambda here to perform variable capture on the 'this' reference
return (event: LanguageServiceContracts.IntelliSenseReadyParams): void => {
this._statusView.languageServiceStatusChanged(event.ownerUri, LocalizedConstants.intelliSenseUpdatedStatus);
let connection = this.getConnectionInfo(event.ownerUri);
if (connection !== undefined) {
let numberOfCharacters: number = 0;
if (this.vscodeWrapper.activeTextEditor !== undefined
&& this.vscodeWrapper.activeTextEditor.document !== undefined) {
let document = this.vscodeWrapper.activeTextEditor.document;
numberOfCharacters = document.getText().length;
}
}
};
}
@ -821,18 +812,5 @@ export default class ConnectionManager {
this.azureController.removeToken(answers.account);
}
});
}
private getIsServerLinux(osVersion: string): string {
if (osVersion) {
if (osVersion.indexOf('Linux') !== -1) {
return 'Linux';
} else {
return 'Windows';
}
}
return '';
}
}

Просмотреть файл

@ -56,7 +56,7 @@ export default class MainController implements vscode.Disposable {
private _queryHistoryProvider: QueryHistoryProvider;
private _scriptingService: ScriptingService;
private _queryHistoryRegistered: boolean = false;
private _sqlTasksService: SqlTasksService;
public sqlTasksService: SqlTasksService;
public dacFxService: DacFxService;
public schemaCompareService: SchemaCompareService;
@ -150,7 +150,7 @@ export default class MainController implements vscode.Disposable {
this.initializeQueryHistory();
this._sqlTasksService = new SqlTasksService(SqlToolsServerClient.instance, this._untitledSqlDocumentService);
this.sqlTasksService = new SqlTasksService(SqlToolsServerClient.instance, this._untitledSqlDocumentService);
this.dacFxService = new DacFxService(SqlToolsServerClient.instance);
this.schemaCompareService = new SchemaCompareService(SqlToolsServerClient.instance);

Просмотреть файл

@ -51,7 +51,6 @@ export class ConnectionProfile extends ConnectionCredentials implements IConnect
profile.authenticationType = authOptions[0].value;
}
let azureController = new AzureController(context);
let azureAuthChoices: INameValueChoice[] = ConnectionProfile.getAzureAuthChoices();
let azureAccountChoices: INameValueChoice[] = ConnectionProfile.getAccountChoices(accountStore);
let accountAnswer: IAccount;
azureAccountChoices.unshift({ name: LocalizedConstants.azureAddAccount, value: 'addAccount'});

Просмотреть файл

@ -25,8 +25,6 @@ const msInS = 1000;
const configTracingLevel = 'tracingLevel';
const configLogRetentionMinutes = 'logRetentionMinutes';
const configLogFilesRemovalLimit = 'logFilesRemovalLimit';
const extensionConfigSectionName = 'mssql';
const configLogDebugInfo = 'logDebugInfo';
// INTERFACES /////////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -436,7 +436,7 @@ export class ObjectExplorerService {
await this._connectionManager.vscodeWrapper.showErrorMessage(
errorMessage, LocalizedConstants.refreshTokenLabel).then(async result => {
if (result === LocalizedConstants.refreshTokenLabel) {
let refreshedProfile = await azureController.getTokens(
await azureController.getTokens(
profile, this._connectionManager.accountStore, providerSettings.resources.databaseResource);
} else {

Просмотреть файл

@ -2,7 +2,6 @@
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
import { OutputChannel } from 'vscode';
import * as Constants from '../constants/constants';
import * as nodeUtil from 'util';
import PromptFactory from './factory';
import EscapeException from '../utils/EscapeException';

Просмотреть файл

@ -6,7 +6,6 @@
import * as vscode from 'vscode';
import * as path from 'path';
import * as LocalizedConstants from '../constants/localizedConstants';
import { queryHistory } from '../constants/constants';
/**
* Empty Node shown when no queries are available

Просмотреть файл

@ -38,7 +38,7 @@ export class QueryHistoryProvider implements vscode.TreeDataProvider<any> {
) {
const config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName);
this._queryHistoryLimit = config.get(Constants.configQueryHistoryLimit);
this._queryHistoryUI = new QueryHistoryUI(this._prompter, this._vscodeWrapper);
this._queryHistoryUI = new QueryHistoryUI(this._prompter);
}
clearAll(): void {

Просмотреть файл

@ -21,9 +21,7 @@ import { AccountStore } from '../azure/accountStore';
import { AzureController } from '../azure/azureController';
import { IAccount } from '../models/contracts/azure/accountInterfaces';
import providerSettings from '../azure/providerSettings';
import * as ConnectionContracts from '../models/contracts/connection';
import { IConnectionInfo } from 'vscode-mssql';
import { Deferred } from '../protocol';
/**
* The different tasks for managing connection profiles.

Просмотреть файл

@ -4,7 +4,7 @@
* ------------------------------------------------------------------------------------------ */
import { Component, OnInit, Inject, forwardRef, ViewChild, ViewChildren, QueryList, ElementRef,
EventEmitter, ChangeDetectorRef, AfterViewChecked } from '@angular/core';
EventEmitter, AfterViewChecked } from '@angular/core';
import { IObservableCollection, SlickGrid, VirtualizedCollection } from 'angular2-slickgrid';
import { ISlickRange, FieldType, IColumnDefinition, IGridDataRow,
IGridIcon, IMessage, IRange, ISelectionData, DbCellValue } from '../../../../../models/interfaces';
@ -153,19 +153,18 @@ export class AppComponent implements OnInit, AfterViewChecked {
private scrollTimeOutTime = 200;
private windowSize = 50;
private maxScrollGrids = 8;
private selectionModel = 'DragRowSelectionModel';
private slickgridPlugins = ['AutoColumnSize'];
public selectionModel = 'DragRowSelectionModel';
public slickgridPlugins = ['AutoColumnSize'];
private _rowHeight = 29;
private _resultsPaneBoundary = 22;
private _defaultNumShowingRows = 8;
private Constants = Constants;
private Utils = Utils;
private _messagesPaneHeight: number;
public Constants = Constants;
public Utils = Utils;
// the function implementations of keyboard available events
private shortcutfunc = {
'event.focusResultsGrid': () => {
this.slickgrids.toArray()[this.activeGrid]._grid.setActiveCell(0, 1);
this.slickgrids.toArray()[this.activeGrid]['_grid'].setActiveCell(0, 1);
},
'event.toggleResultPane': () => {
this.resultActive = !this.resultActive;
@ -276,7 +275,7 @@ export class AppComponent implements OnInit, AfterViewChecked {
}
];
private startString = new Date().toLocaleTimeString();
public startString = new Date().toLocaleTimeString();
private config;
// FIELDS
@ -289,21 +288,21 @@ export class AppComponent implements OnInit, AfterViewChecked {
private messages: IMessage[] = [];
private scrollTimeOut: NodeJS.Timeout;
private messagesAdded = false;
private resizing = false;
private resizeHandleTop = 0;
private scrollEnabled = true;
public resizing = false;
public resizeHandleTop = 0;
public scrollEnabled = true;
private resultActive = true;
private _messageActive = true;
private firstRender = true;
private resultsScrollTop = 0;
public resultsScrollTop = 0;
private activeGrid = 0;
private messageShortcut;
private resultShortcut;
private totalElapsedTimeSpan: number;
private complete = false;
public messageShortcut;
public resultShortcut;
public totalElapsedTimeSpan: number;
public complete = false;
private uri: string;
private hasRunQuery: boolean = false;
private resultsFontSize;
public resultsFontSize;
@ViewChild('contextmenu') contextMenu: ContextMenu;
@ViewChild('messagescontextmenu') messagesContextMenu: MessagesContextMenu;
@ViewChildren('slickgrid') slickgrids: QueryList<SlickGrid>;
@ -321,8 +320,7 @@ export class AppComponent implements OnInit, AfterViewChecked {
constructor(@Inject(forwardRef(() => DataService)) public dataService: DataService,
@Inject(forwardRef(() => ShortcutService)) private shortcuts: ShortcutService,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(forwardRef(() => ChangeDetectorRef)) private cd: ChangeDetectorRef) {}
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef) {}
/**
* Called by Angular when the component is initialized
@ -469,7 +467,7 @@ export class AppComponent implements OnInit, AfterViewChecked {
* Toggle the messages pane
*/
private toggleMessagesPane(): void {
this.messageActive = !this.messageActive
this.messageActive = !this.messageActive;
if (this.messageActive) {
this.resizeResults();
}
@ -501,7 +499,7 @@ export class AppComponent implements OnInit, AfterViewChecked {
/**
* Handles toggling messages via key event
*/
private handleMessagesKeydown(event: KeyboardEvent): void {
public handleMessagesKeydown(event: KeyboardEvent): void {
if (this.handleKeydown(event)) {
this.toggleMessagesPane();
}
@ -510,7 +508,7 @@ export class AppComponent implements OnInit, AfterViewChecked {
/**
* Handles toggling messages via key event
*/
private handleResultsKeydown(event: KeyboardEvent): void {
public handleResultsKeydown(event: KeyboardEvent): void {
if (this.handleKeydown(event)) {
this.toggleResultsPane();
}
@ -793,22 +791,20 @@ export class AppComponent implements OnInit, AfterViewChecked {
* Sets up the resize for the messages/results panes bar
*/
setupResizeBind(): void {
const self = this;
let $resizeHandle = $(self._el.nativeElement.querySelector('#messageResizeHandle'));
let $messagePane = $(self._el.nativeElement.querySelector('#messages'));
let $resizeHandle = $(this._el.nativeElement.querySelector('#messageResizeHandle'));
let $messagePane = $(this._el.nativeElement.querySelector('#messages'));
$resizeHandle.bind('dragstart', (e) => {
self.resizing = true;
self.resizeHandleTop = e.pageY;
this._messagesPaneHeight = $('#messages').get(0).clientHeight;
this.resizing = true;
this.resizeHandleTop = e.pageY;
return true;
});
$resizeHandle.bind('drag', (e) => {
self.resizeHandleTop = e.pageY;
this.resizeHandleTop = e.pageY;
});
$resizeHandle.bind('dragend', (e) => {
self.resizing = false;
this.resizing = false;
// redefine the min size for the messages based on the final position
$messagePane.css('min-height', $(window).height() - (e.pageY + 22));
this.resizeResults();

Просмотреть файл

@ -37,7 +37,7 @@ const template = `
export class ContextMenu implements OnInit {
// tslint:disable-next-line:no-unused-variable
private Constants = Constants;
public Constants = Constants;
@Output() clickEvent: EventEmitter<{type: string, batchId: number, resultId: number, index: number, selection: ISlickRange[]}>
= new EventEmitter<{type: string, batchId: number, resultId: number, index: number, selection: ISlickRange[]}>();
@ -46,8 +46,8 @@ export class ContextMenu implements OnInit {
private index: number;
private selection: ISlickRange[];
private isDisabled: boolean;
private position: {x: number, y: number} = {x: 0, y: 0};
private visible: boolean = false;
public position: {x: number, y: number} = {x: 0, y: 0};
public visible: boolean = false;
private keys = {
'event.saveAsCSV': '',
'event.saveAsJSON': '',

Просмотреть файл

@ -27,15 +27,15 @@ const template = `
})
export class MessagesContextMenu implements OnInit {
private Utils = Utils;
private Constants = Constants;
public Utils = Utils;
public Constants = Constants;
@Output() clickEvent: EventEmitter<{type: string, selectedRange: IRange }>
= new EventEmitter<{type: string, selectedRange: IRange}>();
private selectedRange: IRange;
private isDisabled: boolean;
private position: {x: number, y: number} = {x: 0, y: 0};
private visible: boolean = false;
public position: {x: number, y: number} = {x: 0, y: 0};
public visible: boolean = false;
private keys = {
'event.copySelection': ''
};

Просмотреть файл

@ -5,7 +5,6 @@
import * as vscode from 'vscode';
import * as Utils from '../models/utils';
import VscodeWrapper from '../controllers/vscodeWrapper';
import { IPrompter, IQuestion, QuestionTypes } from '../prompts/question';
import { QueryHistoryNode } from '../queryHistory/queryHistoryNode';
import * as LocalizedConstants from '../constants/localizedConstants';
@ -25,8 +24,7 @@ export interface QueryHistoryQuickPickItem extends vscode.QuickPickItem {
export class QueryHistoryUI {
constructor(
private _prompter: IPrompter,
private _vscodeWrapper: VscodeWrapper
private _prompter: IPrompter
) {}
public convertToQuickPickItem(node: vscode.TreeItem): QueryHistoryQuickPickItem {

Просмотреть файл

@ -1,58 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import * as vscode from 'vscode';
import * as TypeMoq from 'typemoq';
import SqlToolsServiceClient from '../src/languageservice/serviceclient';
import { AccountService } from '../src/azure/accountService';
import { HandleFirewallRuleRequest, IHandleFirewallRuleResponse,
CreateFirewallRuleRequest, ICreateFirewallRuleResponse, IHandleFirewallRuleParams } from '../src/models/contracts/firewall/firewallRequest';
import VscodeWrapper from '../src/controllers/vscodeWrapper';
import { assert } from 'chai';
import { IAzureSession } from '../src/models/interfaces';
suite('Firewall Service Tests', () => {
let accountService: AccountService;
let client: TypeMoq.IMock<SqlToolsServiceClient>;
let vscodeWrapper: TypeMoq.IMock<VscodeWrapper>;
setup(() => {
client = TypeMoq.Mock.ofType(SqlToolsServiceClient, TypeMoq.MockBehavior.Loose);
let mockHandleFirewallResponse: IHandleFirewallRuleResponse = {
result: true,
ipAddress: '128.0.0.0'
};
let mockCreateFirewallRuleResponse: ICreateFirewallRuleResponse = {
result: true,
errorMessage: ''
};
client.setup(c => c.sendResourceRequest(HandleFirewallRuleRequest.type, TypeMoq.It.isAny())).returns(() => Promise.resolve(mockHandleFirewallResponse));
client.setup(c => c.sendResourceRequest(CreateFirewallRuleRequest.type,
TypeMoq.It.isAny())).returns(() => Promise.resolve(mockCreateFirewallRuleResponse));
vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
let mockSession: IAzureSession = {
environment: undefined,
userId: 'test',
tenantId: 'test',
credentials: undefined
};
let mockExtension: vscode.Extension<any> = {
id: '',
extensionKind: undefined,
extensionPath: '',
isActive: true,
packageJSON: undefined,
activate: undefined,
extensionUri: undefined,
exports: {
sessions: [mockSession]
}
};
vscodeWrapper.setup(v => v.azureAccountExtension).returns(() => mockExtension);
accountService = new AccountService(client.object, vscodeWrapper.object, undefined, undefined);
});
});

Просмотреть файл

@ -8,45 +8,45 @@ import * as figures from 'figures';
import VscodeWrapper from '../src/controllers/vscodeWrapper';
import CheckboxPrompt from '../src/prompts/checkbox';
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
suite('Test Checkbox prompt', () => {
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
// test('Test checkbox prompt with simple question', () => {
// let question = {
// choices: [{ name: 'test1', checked: true }, { name: 'test2', checked: false }]
// };
// let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
// vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny())).returns(() => Promise.resolve('test1'));
// let checkbox = new CheckboxPrompt(question, vscodeWrapper.object);
// checkbox.render();
// vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
test('Test checkbox prompt with simple question', () => {
let question = {
choices: [{ name: 'test1', checked: true }, { name: 'test2', checked: false }]
};
let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny())).returns(() => Promise.resolve('test1'));
let checkbox = new CheckboxPrompt(question, vscodeWrapper.object);
checkbox.render();
vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny()), TypeMoq.Times.once());
});
// test('Test Checkbox prompt with error', () => {
// let question = {
// choices: [{ name: 'test1', checked: true }, { name: 'test2', checked: false }]
// };
// let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
// vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
// let checkbox = new CheckboxPrompt(question, vscodeWrapper.object);
// checkbox.render();
// vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
test('Test Checkbox prompt with error', () => {
let question = {
choices: [{ name: 'test1', checked: true }, { name: 'test2', checked: false }]
};
let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
let checkbox = new CheckboxPrompt(question, vscodeWrapper.object);
checkbox.render();
vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny()), TypeMoq.Times.once());
});
// test('Test Checkbox prompt with checked answer', () => {
// let question = {
// choices: [{ name: 'test1', checked: true }, { name: 'test2', checked: false }]
// };
// let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
// vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny())).returns(() => Promise.resolve(figures.tick));
// let checkbox = new CheckboxPrompt(question, vscodeWrapper.object);
// checkbox.render();
// vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
test('Test Checkbox prompt with checked answer', () => {
let question = {
choices: [{ name: 'test1', checked: true }, { name: 'test2', checked: false }]
};
let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny())).returns(() => Promise.resolve(figures.tick));
let checkbox = new CheckboxPrompt(question, vscodeWrapper.object);
checkbox.render();
vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny()), TypeMoq.Times.once());
});
});

Просмотреть файл

@ -3,32 +3,37 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
suite('Test Confirm Prompt', () => {
import * as TypeMoq from 'typemoq';
import VscodeWrapper from '../src/controllers/vscodeWrapper';
import * as LocalizedConstants from '../src/constants/localizedConstants';
import ConfirmPrompt from '../src/prompts/confirm';
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
// test('Test Confirm prompt with simple question', () => {
// let question = {
// name: 'test'
// };
// let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
// vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny())).returns(() => Promise.resolve(LocalizedConstants.msgYes));
// let confirm = new ConfirmPrompt(question, vscodeWrapper.object);
// confirm.render();
// vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
suite.skip('Test Confirm Prompt', () => {
// test('Test Checkbox prompt with error', () => {
// let question = {
// name: 'test'
// };
// let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
// vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
// let confirm = new ConfirmPrompt(question, vscodeWrapper.object);
// confirm.render();
// vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
test('Test Confirm prompt with simple question', () => {
let question = {
name: 'test'
};
let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny())).returns(() => Promise.resolve(LocalizedConstants.msgYes));
let confirm = new ConfirmPrompt(question, vscodeWrapper.object);
confirm.render();
vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny()), TypeMoq.Times.once());
});
test('Test Checkbox prompt with error', () => {
let question = {
name: 'test'
};
let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
let confirm = new ConfirmPrompt(question, vscodeWrapper.object);
confirm.render();
vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny()), TypeMoq.Times.once());
});
});

Просмотреть файл

@ -15,7 +15,6 @@ import { ConnectionProfile } from '../src/models/connectionProfile';
import { ConnectionCredentials } from '../src/models/connectionCredentials';
import * as LocalizedConstants from '../src/constants/localizedConstants';
import { AccountStore } from '../src/azure/accountStore';
import { IConnectionInfo } from 'vscode-mssql';
suite('Connection UI tests', () => {

Просмотреть файл

@ -172,43 +172,43 @@ suite('ServiceDownloadProvider Tests', () => {
});
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
// test('installSQLToolsService should not call decompress if download fails', () => {
// let fixture: IFixture = {
// downloadUrl: undefined,
// downloadProvider: undefined,
// downloadResult: Promise.reject('download failed'),
// decompressResult: Promise.resolve()
// };
test.skip('installSQLToolsService should not call decompress if download fails', () => {
let fixture: IFixture = {
downloadUrl: undefined,
downloadProvider: undefined,
downloadResult: Promise.reject('download failed'),
decompressResult: Promise.resolve()
};
// fixture = createDownloadProvider(fixture);
// return fixture.downloadProvider.installSQLToolsService(Runtime.Windows_7_64).catch(_ => {
// testHttpClient.verify(x => x.downloadFile(fixture.downloadUrl, TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(),
// TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()),
// TypeMoq.Times.once());
// testDecompressProvider.verify(x => x.decompress(TypeMoq.It.isAny(), TypeMoq.It.isAny()),
// TypeMoq.Times.never());
// testStatusView.verify(x => x.installingService(), TypeMoq.Times.never());
// testStatusView.verify(x => x.serviceInstalled(), TypeMoq.Times.never());
// });
// });
fixture = createDownloadProvider(fixture);
return fixture.downloadProvider.installSQLToolsService(Runtime.Windows_7_64).catch(_ => {
testHttpClient.verify(x => x.downloadFile(fixture.downloadUrl, TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(),
TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()),
TypeMoq.Times.once());
testDecompressProvider.verify(x => x.decompress(TypeMoq.It.isAny(), TypeMoq.It.isAny()),
TypeMoq.Times.never());
testStatusView.verify(x => x.installingService(), TypeMoq.Times.never());
testStatusView.verify(x => x.serviceInstalled(), TypeMoq.Times.never());
});
});
// test('installSQLToolsService should not update status to installed decompress fails', () => {
// let fixture: IFixture = {
// downloadUrl: undefined,
// downloadProvider: undefined,
// downloadResult: Promise.resolve(),
// decompressResult: Promise.reject('download failed')
// };
test.skip('installSQLToolsService should not update status to installed decompress fails', () => {
let fixture: IFixture = {
downloadUrl: undefined,
downloadProvider: undefined,
downloadResult: Promise.resolve(),
decompressResult: Promise.reject('download failed')
};
// fixture = createDownloadProvider(fixture);
// return fixture.downloadProvider.installSQLToolsService(Runtime.Windows_7_64).catch(_ => {
// testHttpClient.verify(x => x.downloadFile(fixture.downloadUrl, TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(),
// TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()),
// TypeMoq.Times.once());
// testDecompressProvider.verify(x => x.decompress(TypeMoq.It.isAny(), TypeMoq.It.isAny()),
// TypeMoq.Times.once());
// testStatusView.verify(x => x.installingService(), TypeMoq.Times.once());
// testStatusView.verify(x => x.serviceInstalled(), TypeMoq.Times.never());
// });
// });
fixture = createDownloadProvider(fixture);
return fixture.downloadProvider.installSQLToolsService(Runtime.Windows_7_64).catch(_ => {
testHttpClient.verify(x => x.downloadFile(fixture.downloadUrl, TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(),
TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()),
TypeMoq.Times.once());
testDecompressProvider.verify(x => x.decompress(TypeMoq.It.isAny(), TypeMoq.It.isAny()),
TypeMoq.Times.once());
testStatusView.verify(x => x.installingService(), TypeMoq.Times.once());
testStatusView.verify(x => x.serviceInstalled(), TypeMoq.Times.never());
});
});
});

Просмотреть файл

@ -6,7 +6,6 @@
import * as vscode from 'vscode';
import * as TypeMoq from 'typemoq';
import VscodeWrapper from '../src/controllers/vscodeWrapper';
import * as LocalizedConstants from '../src/constants/localizedConstants';
import ExpandPrompt from '../src/prompts/expand';
suite('Test Expand Prompt', () => {
@ -26,51 +25,51 @@ suite('Test Expand Prompt', () => {
});
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
// test('Test expand prompt with error question', () => {
// let question = {
// choices: [{ name: 'test', value: 'test' }],
// validate: (e) => true
// };
// let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
// vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
// let expand = new ExpandPrompt(question, vscodeWrapper.object);
// expand.render();
// vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
test.skip('Test expand prompt with error question', () => {
let question = {
choices: [{ name: 'test', value: 'test' }],
validate: (e) => true
};
let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
vscodeWrapper.setup(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
let expand = new ExpandPrompt(question, vscodeWrapper.object);
expand.render();
vscodeWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny()), TypeMoq.Times.once());
});
// test('Test expand prompt with quick pick item', () => {
// let quickPickItem: vscode.QuickPickItem = {
// label: 'test'
// };
// let question = {
// choices: [quickPickItem],
// validate: (e) => true
// };
// let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
// vscodeWrapper.setup(v => v.showQuickPick(TypeMoq.It.isAny(),
// TypeMoq.It.isAny())).returns(() => Promise.resolve(quickPickItem));
// let expand = new ExpandPrompt(question, vscodeWrapper.object);
// expand.render();
// vscodeWrapper.verify(v => v.showQuickPick(TypeMoq.It.isAny(),
// TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
test.skip('Test expand prompt with quick pick item', () => {
let quickPickItem: vscode.QuickPickItem = {
label: 'test'
};
let question = {
choices: [quickPickItem],
validate: (e) => true
};
let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
vscodeWrapper.setup(v => v.showQuickPick(TypeMoq.It.isAny(),
TypeMoq.It.isAny())).returns(() => Promise.resolve(quickPickItem));
let expand = new ExpandPrompt(question, vscodeWrapper.object);
expand.render();
vscodeWrapper.verify(v => v.showQuickPick(TypeMoq.It.isAny(),
TypeMoq.It.isAny()), TypeMoq.Times.once());
});
// test('Test expand prompt with error quick pick item', () => {
// let quickPickItem: vscode.QuickPickItem = {
// label: 'test'
// };
// let question = {
// choices: [quickPickItem],
// validate: (e) => false
// };
// let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
// vscodeWrapper.setup(v => v.showQuickPick(TypeMoq.It.isAny(),
// TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
// let expand = new ExpandPrompt(question, vscodeWrapper.object);
// expand.render();
// vscodeWrapper.verify(v => v.showQuickPick(TypeMoq.It.isAny(),
// TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
test.skip('Test expand prompt with error quick pick item', () => {
let quickPickItem: vscode.QuickPickItem = {
label: 'test'
};
let question = {
choices: [quickPickItem],
validate: (e) => false
};
let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
vscodeWrapper.setup(v => v.showQuickPick(TypeMoq.It.isAny(),
TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
let expand = new ExpandPrompt(question, vscodeWrapper.object);
expand.render();
vscodeWrapper.verify(v => v.showQuickPick(TypeMoq.It.isAny(),
TypeMoq.It.isAny()), TypeMoq.Times.once());
});
});

Просмотреть файл

@ -8,7 +8,7 @@ import SqlToolsServiceClient from '../src/languageservice/serviceclient';
import { FirewallService } from '../src/firewall/firewallService';
import { AccountService } from '../src/azure/accountService';
import { HandleFirewallRuleRequest, IHandleFirewallRuleResponse,
CreateFirewallRuleRequest, ICreateFirewallRuleResponse, IHandleFirewallRuleParams } from '../src/models/contracts/firewall/firewallRequest';
CreateFirewallRuleRequest, ICreateFirewallRuleResponse } from '../src/models/contracts/firewall/firewallRequest';
import VscodeWrapper from '../src/controllers/vscodeWrapper';
import { assert } from 'chai';
import { IAzureSession, IAzureResourceFilter } from '../src/models/interfaces';

Просмотреть файл

@ -6,8 +6,6 @@
import * as TypeMoq from 'typemoq';
import VscodeWrapper from '../src/controllers/vscodeWrapper';
import InputPrompt from '../src/prompts/input';
import { assert } from 'chai';
import EscapeException from '../src/utils/EscapeException';
suite('Input Prompt Tests', () => {
@ -30,17 +28,17 @@ suite('Input Prompt Tests', () => {
vscodeWrapper.verify(v => v.showInputBox(TypeMoq.It.isAny()), TypeMoq.Times.once());
});
// test('Test prompt an error question should throw', () => {
// let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
// const errorQuestion = {
// default: new Error('test'),
// placeHolder: undefined
// };
// vscodeWrapper.setup(v => v.showInputBox(TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
// let listPrompt = new InputPrompt(errorQuestion, vscodeWrapper.object);
// listPrompt.render();
// vscodeWrapper.verify(v => v.showInputBox(TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
test.skip('Test prompt an error question should throw', () => {
let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
const errorQuestion = {
default: new Error('test'),
placeHolder: undefined
};
vscodeWrapper.setup(v => v.showInputBox(TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
let listPrompt = new InputPrompt(errorQuestion, vscodeWrapper.object);
listPrompt.render();
vscodeWrapper.verify(v => v.showInputBox(TypeMoq.It.isAny()), TypeMoq.Times.once());
});
test('Test prompt question with default message', () => {
let vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);

Просмотреть файл

@ -30,14 +30,14 @@ suite('List Prompt Tests', () => {
});
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
// test('Test list prompt render with error', () => {
// let errorWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
// errorWrapper.setup(w => w.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
// let errorPrompt = new ListPrompt(question, errorWrapper.object);
// errorPrompt.render();
// errorWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
// TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
test.skip('Test list prompt render with error', () => {
let errorWrapper = TypeMoq.Mock.ofType(VscodeWrapper, TypeMoq.MockBehavior.Loose);
errorWrapper.setup(w => w.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
let errorPrompt = new ListPrompt(question, errorWrapper.object);
errorPrompt.render();
errorWrapper.verify(v => v.showQuickPickStrings(TypeMoq.It.isAny(),
TypeMoq.It.isAny()), TypeMoq.Times.once());
});
});

Просмотреть файл

@ -16,6 +16,7 @@ import * as LocalizedConstants from '../src/constants/localizedConstants';
import { AccountSignInTreeNode } from '../src/objectExplorer/accountSignInTreeNode';
import { ConnectTreeNode } from '../src/objectExplorer/connectTreeNode';
import { NodeInfo } from '../src/models/contracts/objectExplorer/nodeInfo';
import { Deferred } from '../src/protocol';
suite('Object Explorer Provider Tests', () => {
@ -38,28 +39,28 @@ suite('Object Explorer Provider Tests', () => {
});
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
// test('Test Create Session', () => {
// expect(objectExplorerService.object.currentNode, 'Current Node should be undefined').is.equal(undefined);
// expect(objectExplorerProvider.objectExplorerExists, 'Object Explorer should not exist until started').is.equal(undefined);
// const promise = new Deferred<TreeNodeInfo>();
// objectExplorerService.setup(s => s.createSession(promise, undefined)).returns(() => {
// return new Promise((resolve, reject) => {
// objectExplorerService.setup(s => s.currentNode).returns(() => TypeMoq.It.isAny());
// objectExplorerProvider.objectExplorerExists = true;
// promise.resolve(new TreeNodeInfo(undefined, undefined,
// undefined, undefined,
// undefined, undefined,
// undefined, undefined,
// undefined));
// });
// });
// objectExplorerProvider.createSession(promise, undefined).then(async () => {
// expect(objectExplorerService.object.currentNode, 'Current Node should not be undefined').is.not.equal(undefined);
// expect(objectExplorerProvider.objectExplorerExists, 'Object Explorer session should exist').is.equal(true);
// let node = await promise;
// expect(node, 'Created session node not be undefined').is.not.equal(undefined);
// });
// });
test.skip('Test Create Session', () => {
expect(objectExplorerService.object.currentNode, 'Current Node should be undefined').is.equal(undefined);
expect(objectExplorerProvider.objectExplorerExists, 'Object Explorer should not exist until started').is.equal(undefined);
const promise = new Deferred<TreeNodeInfo>();
objectExplorerService.setup(s => s.createSession(promise, undefined)).returns(() => {
return new Promise((resolve, reject) => {
objectExplorerService.setup(s => s.currentNode).returns(() => TypeMoq.It.isAny());
objectExplorerProvider.objectExplorerExists = true;
promise.resolve(new TreeNodeInfo(undefined, undefined,
undefined, undefined,
undefined, undefined,
undefined, undefined,
undefined));
});
});
objectExplorerProvider.createSession(promise, undefined).then(async () => {
expect(objectExplorerService.object.currentNode, 'Current Node should not be undefined').is.not.equal(undefined);
expect(objectExplorerProvider.objectExplorerExists, 'Object Explorer session should exist').is.equal(true);
let node = await promise;
expect(node, 'Created session node not be undefined').is.not.equal(undefined);
});
});
test('Test Refresh Node', (done) => {
let treeNode = TypeMoq.Mock.ofType(TreeNodeInfo, TypeMoq.MockBehavior.Loose);

Просмотреть файл

@ -46,41 +46,41 @@ suite('Service Client tests', () => {
}
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
// test('initializeForPlatform should not install the service if already exists', (done) => {
// let fixture: IFixture = {
// installedServerPath: 'already installed service',
// downloadedServerPath: undefined,
// platformInfo: new PlatformInformation('win32', 'x86_64', undefined)
// };
test.skip('initializeForPlatform should not install the service if already exists', (done) => {
let fixture: IFixture = {
installedServerPath: 'already installed service',
downloadedServerPath: undefined,
platformInfo: new PlatformInformation('win32', 'x86_64', undefined)
};
// setupMocks(fixture);
// let serviceClient = new SqlToolsServiceClient(testConfig.object, testServiceProvider.object, logger, testStatusView.object, vscodeWrapper.object);
setupMocks(fixture);
let serviceClient = new SqlToolsServiceClient(testConfig.object, testServiceProvider.object, logger, testStatusView.object, vscodeWrapper.object);
// serviceClient.initializeForPlatform(fixture.platformInfo, undefined).then( result => {
// assert.notEqual(result, undefined);
// assert.equal(result.serverPath, fixture.installedServerPath);
// assert.equal(result.installedBeforeInitializing, false);
// });
// done();
// });
serviceClient.initializeForPlatform(fixture.platformInfo, undefined).then( result => {
assert.notEqual(result, undefined);
assert.equal(result.serverPath, fixture.installedServerPath);
assert.equal(result.installedBeforeInitializing, false);
});
done();
});
// test('initializeForPlatform should install the service if not exists', (done) => {
// let fixture: IFixture = {
// installedServerPath: undefined,
// downloadedServerPath: 'downloaded service',
// platformInfo: new PlatformInformation('win32', 'x86_64', undefined)
// };
test.skip('initializeForPlatform should install the service if not exists', (done) => {
let fixture: IFixture = {
installedServerPath: undefined,
downloadedServerPath: 'downloaded service',
platformInfo: new PlatformInformation('win32', 'x86_64', undefined)
};
// setupMocks(fixture);
// let serviceClient = new SqlToolsServiceClient(testConfig.object, testServiceProvider.object, logger, testStatusView.object, vscodeWrapper.object);
setupMocks(fixture);
let serviceClient = new SqlToolsServiceClient(testConfig.object, testServiceProvider.object, logger, testStatusView.object, vscodeWrapper.object);
// serviceClient.initializeForPlatform(fixture.platformInfo, undefined).then(result => {
// assert.notEqual(result, undefined);
// assert.equal(result.serverPath, fixture.downloadedServerPath);
// assert.equal(result.installedBeforeInitializing, true);
// });
// done();
// });
serviceClient.initializeForPlatform(fixture.platformInfo, undefined).then(result => {
assert.notEqual(result, undefined);
assert.equal(result.serverPath, fixture.downloadedServerPath);
assert.equal(result.installedBeforeInitializing, true);
});
done();
});
test('initializeForPlatform should fail given unsupported platform', () => {
let fixture: IFixture = {
@ -98,61 +98,61 @@ suite('Service Client tests', () => {
});
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
// test('initializeForPlatform should set v1 given mac 10.11 or lower', (done) => {
// let platformInfoMock = TypeMoq.Mock.ofInstance(new PlatformInformation('darwin', 'x86_64', undefined));
// platformInfoMock.callBase = true;
// platformInfoMock.setup(x => x.isMacVersionLessThan(TypeMoq.It.isAnyString())).returns(() => true);
test.skip('initializeForPlatform should set v1 given mac 10.11 or lower', (done) => {
let platformInfoMock = TypeMoq.Mock.ofInstance(new PlatformInformation('darwin', 'x86_64', undefined));
platformInfoMock.callBase = true;
platformInfoMock.setup(x => x.isMacVersionLessThan(TypeMoq.It.isAnyString())).returns(() => true);
// let fixture: IFixture = {
// installedServerPath: 'already installed service',
// downloadedServerPath: undefined,
// platformInfo: platformInfoMock.object
// };
let fixture: IFixture = {
installedServerPath: 'already installed service',
downloadedServerPath: undefined,
platformInfo: platformInfoMock.object
};
// let serviceVersion: number = 0;
// testConfig.setup(x => x.useServiceVersion(TypeMoq.It.isAnyNumber())).callback(num => serviceVersion = num);
let serviceVersion: number = 0;
testConfig.setup(x => x.useServiceVersion(TypeMoq.It.isAnyNumber())).callback(num => serviceVersion = num);
// setupMocks(fixture);
// let serviceClient = new SqlToolsServiceClient(testConfig.object, testServiceProvider.object, logger, testStatusView.object, vscodeWrapper.object);
setupMocks(fixture);
let serviceClient = new SqlToolsServiceClient(testConfig.object, testServiceProvider.object, logger, testStatusView.object, vscodeWrapper.object);
// serviceClient.initializeForPlatform(fixture.platformInfo, undefined).then( result => {
// assert.equal(serviceVersion, 1);
// platformInfoMock.verify(x => x.isMacVersionLessThan(TypeMoq.It.isAny()), TypeMoq.Times.once());
// testConfig.verify(x => x.useServiceVersion(1), TypeMoq.Times.once());
// assert.notEqual(result, undefined);
// assert.equal(result.serverPath, fixture.installedServerPath);
// assert.equal(result.installedBeforeInitializing, false);
// });
// done();
// });
serviceClient.initializeForPlatform(fixture.platformInfo, undefined).then( result => {
assert.equal(serviceVersion, 1);
platformInfoMock.verify(x => x.isMacVersionLessThan(TypeMoq.It.isAny()), TypeMoq.Times.once());
testConfig.verify(x => x.useServiceVersion(1), TypeMoq.Times.once());
assert.notEqual(result, undefined);
assert.equal(result.serverPath, fixture.installedServerPath);
assert.equal(result.installedBeforeInitializing, false);
});
done();
});
// test('initializeForPlatform should ignore service version given mac 10.12 or higher', (done) => {
// let platformInfoMock = TypeMoq.Mock.ofInstance(new PlatformInformation('darwin', 'x86_64', undefined));
// platformInfoMock.callBase = true;
// platformInfoMock.setup(x => x.isMacVersionLessThan(TypeMoq.It.isAnyString())).returns(() => false);
test.skip('initializeForPlatform should ignore service version given mac 10.12 or higher', (done) => {
let platformInfoMock = TypeMoq.Mock.ofInstance(new PlatformInformation('darwin', 'x86_64', undefined));
platformInfoMock.callBase = true;
platformInfoMock.setup(x => x.isMacVersionLessThan(TypeMoq.It.isAnyString())).returns(() => false);
// let fixture: IFixture = {
// installedServerPath: 'already installed service',
// downloadedServerPath: undefined,
// platformInfo: platformInfoMock.object
// };
let fixture: IFixture = {
installedServerPath: 'already installed service',
downloadedServerPath: undefined,
platformInfo: platformInfoMock.object
};
// let serviceVersion: number = 0;
// testConfig.setup(x => x.useServiceVersion(TypeMoq.It.isAnyNumber())).callback(num => serviceVersion = num);
let serviceVersion: number = 0;
testConfig.setup(x => x.useServiceVersion(TypeMoq.It.isAnyNumber())).callback(num => serviceVersion = num);
// setupMocks(fixture);
// let serviceClient = new SqlToolsServiceClient(testConfig.object, testServiceProvider.object, logger, testStatusView.object, vscodeWrapper.object);
setupMocks(fixture);
let serviceClient = new SqlToolsServiceClient(testConfig.object, testServiceProvider.object, logger, testStatusView.object, vscodeWrapper.object);
// serviceClient.initializeForPlatform(fixture.platformInfo, undefined).then( result => {
// assert.equal(serviceVersion, 0);
// platformInfoMock.verify(x => x.isMacVersionLessThan(TypeMoq.It.isAny()), TypeMoq.Times.once());
// testConfig.verify(x => x.useServiceVersion(1), TypeMoq.Times.never());
// assert.notEqual(result, undefined);
// assert.equal(result.serverPath, fixture.installedServerPath);
// assert.equal(result.installedBeforeInitializing, false);
// });
// done();
// });
serviceClient.initializeForPlatform(fixture.platformInfo, undefined).then( result => {
assert.equal(serviceVersion, 0);
platformInfoMock.verify(x => x.isMacVersionLessThan(TypeMoq.It.isAny()), TypeMoq.Times.once());
testConfig.verify(x => x.useServiceVersion(1), TypeMoq.Times.never());
assert.notEqual(result, undefined);
assert.equal(result.serverPath, fixture.installedServerPath);
assert.equal(result.installedBeforeInitializing, false);
});
done();
});
test('handleLanguageServiceStatusNotification should change the UI status', (done) => {
return new Promise((resolve, reject) => {

Просмотреть файл

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { assert } from 'chai';
import { StubStatusView, StubLogger, getServiceInstallDirectoryRoot, getServiceInstallDirectory, installService } from '../src/languageservice/serviceInstallerUtil';
import { StubStatusView, StubLogger, getServiceInstallDirectoryRoot, installService } from '../src/languageservice/serviceInstallerUtil';
function setupConsole(): string[] {
let logs = [];

Просмотреть файл

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import { SqlOutputContentProvider, QueryRunnerState } from '../src/models/sqlOutputContentProvider';
import { SqlOutputContentProvider } from '../src/models/sqlOutputContentProvider';
import VscodeWrapper from '../src/controllers/vscodeWrapper';
import StatusView from '../src/views/statusView';
import * as stubs from './stubs';

Просмотреть файл

@ -55,20 +55,20 @@ suite('UntitledSqlDocumentService Tests', () => {
}
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
// test('newQuery should open a new untitled document and show in new tab' , () => {
// let fixture: IFixture = {
// openDocResult: Promise.resolve(createTextDocumentObject()),
// showDocResult: Promise.resolve(TypeMoq.It.isAny()),
// service: undefined,
// vscodeWrapper: undefined,
// textDocuments: []
// };
// fixture = createUntitledSqlDocumentService(fixture);
test.skip('newQuery should open a new untitled document and show in new tab' , () => {
let fixture: IFixture = {
openDocResult: Promise.resolve(createTextDocumentObject()),
showDocResult: Promise.resolve(TypeMoq.It.isAny()),
service: undefined,
vscodeWrapper: undefined,
textDocuments: []
};
fixture = createUntitledSqlDocumentService(fixture);
// fixture.service.newQuery().then(result => {
// fixture.vscodeWrapper.verify(x => x.openMsSqlTextDocument(), TypeMoq.Times.once());
// fixture.vscodeWrapper.verify(x => x.showTextDocument(TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.once());
// });
// });
fixture.service.newQuery().then(result => {
fixture.vscodeWrapper.verify(x => x.openMsSqlTextDocument(), TypeMoq.Times.once());
fixture.vscodeWrapper.verify(x => x.showTextDocument(TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.once());
});
});
});

Просмотреть файл

@ -115,30 +115,30 @@ suite('Utility tests - getSignInQuickPickItems', () => {
});
// @cssuh 10/22 - commented this test because it was throwing some random undefined errors
// suite('Utility tests - Timer Class', () => {
// let timer = new Utils.Timer();
suite.skip('Utility tests - Timer Class', () => {
let timer = new Utils.Timer();
// test('timer should start when initiated', (done) => {
// let p = new Promise((resolve, reject) => {
// setTimeout(() => {
// let duration = timer.getDuration();
// assert.isAbove(duration, 0);
// resolve();
// }, 100);
// });
// p.then(() => done());
// });
test('timer should start when initiated', (done) => {
let p = new Promise<void>((resolve, reject) => {
setTimeout(() => {
let duration = timer.getDuration();
assert.isAbove(duration, 0);
resolve();
}, 100);
});
p.then(() => done());
});
// test('timer should end when ended', (done) => {
// let duration = timer.getDuration();
// timer.end();
// let p = new Promise((resolve, reject) => {
// setTimeout(() => {
// let newDuration = timer.getDuration();
// assert.notEqual(duration, newDuration);
// resolve();
// }, 100);
// });
// p.then(() => done());
// });
// });
test('timer should end when ended', (done) => {
let duration = timer.getDuration();
timer.end();
let p = new Promise<void>((resolve, reject) => {
setTimeout(() => {
let newDuration = timer.getDuration();
assert.notEqual(duration, newDuration);
resolve();
}, 100);
});
p.then(() => done());
});
});

Просмотреть файл

@ -9,7 +9,8 @@
"allowUnusedLabels": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"rootDir": "."
"rootDir": ".",
"noUnusedLocals": true
},
"exclude": [
"node_modules"