Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/simulation/slash-test/testGen.csharp.stest.ts
13394 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as assert from 'assert';
7
import { Intent } from '../../../src/extension/common/constants';
8
import { isQualifiedFile, isRelativeFile } from '../../../src/platform/test/node/simulationWorkspace';
9
import { Schemas } from '../../../src/util/vs/base/common/network';
10
import { ssuite, stest } from '../../base/stest';
11
import { forInline, simulateInlineChatWithStrategy } from '../inlineChatSimulator';
12
import { getFileContent } from '../outcomeValidators';
13
import { assertSomeStrings, assertWorkspaceEdit, fromFixture } from '../stestUtil';
14
15
forInline((strategy, nonExtensionConfigurations, suffix) => {
16
17
ssuite({ title: `/tests${suffix}`, location: 'inline', language: 'csharp', nonExtensionConfigurations }, () => {
18
19
stest({ description: 'creates new test file with some assertions and uses correct file name', }, (testingServiceCollection) => {
20
return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {
21
files: [
22
fromFixture('tests/cs-newtest/', 'src/services/Model.cs'),
23
],
24
queries: [{
25
file: 'src/services/Model.cs',
26
selection: [4, 8, 4, 8],
27
query: '/tests',
28
expectedIntent: Intent.Tests,
29
validate: async (outcome, workspace, accessor) => {
30
assertWorkspaceEdit(outcome);
31
32
assert.strictEqual(outcome.files.length, 1);
33
34
const [first] = outcome.files;
35
36
assertSomeStrings(getFileContent(first), ['Assert', 'Test', 'MyObject', 'MyMethod']);
37
if (isQualifiedFile(first)) {
38
assert.strictEqual(first.uri.scheme, Schemas.untitled);
39
assert.ok(first.uri.path.endsWith('ModelTest.cs'));
40
} else if (isRelativeFile(first)) {
41
assert.ok(first.fileName.endsWith('ModelTest.cs'));
42
}
43
}
44
}]
45
});
46
});
47
48
});
49
50
});
51
52