Path: blob/main/extensions/copilot/test/simulation/slash-test/testGen.csharp.stest.ts
13394 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as assert from 'assert';6import { Intent } from '../../../src/extension/common/constants';7import { isQualifiedFile, isRelativeFile } from '../../../src/platform/test/node/simulationWorkspace';8import { Schemas } from '../../../src/util/vs/base/common/network';9import { ssuite, stest } from '../../base/stest';10import { forInline, simulateInlineChatWithStrategy } from '../inlineChatSimulator';11import { getFileContent } from '../outcomeValidators';12import { assertSomeStrings, assertWorkspaceEdit, fromFixture } from '../stestUtil';1314forInline((strategy, nonExtensionConfigurations, suffix) => {1516ssuite({ title: `/tests${suffix}`, location: 'inline', language: 'csharp', nonExtensionConfigurations }, () => {1718stest({ description: 'creates new test file with some assertions and uses correct file name', }, (testingServiceCollection) => {19return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {20files: [21fromFixture('tests/cs-newtest/', 'src/services/Model.cs'),22],23queries: [{24file: 'src/services/Model.cs',25selection: [4, 8, 4, 8],26query: '/tests',27expectedIntent: Intent.Tests,28validate: async (outcome, workspace, accessor) => {29assertWorkspaceEdit(outcome);3031assert.strictEqual(outcome.files.length, 1);3233const [first] = outcome.files;3435assertSomeStrings(getFileContent(first), ['Assert', 'Test', 'MyObject', 'MyMethod']);36if (isQualifiedFile(first)) {37assert.strictEqual(first.uri.scheme, Schemas.untitled);38assert.ok(first.uri.path.endsWith('ModelTest.cs'));39} else if (isRelativeFile(first)) {40assert.ok(first.fileName.endsWith('ModelTest.cs'));41}42}43}]44});45});4647});4849});505152