Skip to content

Commit

Permalink
Make hover test run by adding the file in the project (dotnet#2058)
Browse files Browse the repository at this point in the history
* Added hover.cs file

* Not requiring server restart
  • Loading branch information
akshita31 committed Feb 23, 2018
1 parent c6cf2d7 commit 8f178ab
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 40 deletions.
62 changes: 22 additions & 40 deletions test/integrationTests/hoverProvider.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import * as fs from 'async-file';
import * as vscode from 'vscode';
import * as path from 'path';

import poll from './poll';
import { should, expect } from 'chai';
Expand All @@ -13,62 +14,43 @@ import { RequestQueueCollection } from '../../src/omnisharp/requestQueue';
import { OmniSharpServer } from '../../src/omnisharp/server';
import { omnisharp } from '../../src/omnisharp/extension';

const chai = require('chai');
chai.use(require('chai-arrays'));
chai.use(require('chai-fs'));
const chai = require('chai');
chai.use(require('chai-arrays'));
chai.use(require('chai-fs'));

suite(`Hover Provider: ${testAssetWorkspace.description}`, function() {
suiteSetup(async function() {
suite(`Hover Provider: ${testAssetWorkspace.description}`, function () {
suiteSetup(async function () {
should();

let csharpExtension = vscode.extensions.getExtension("ms-vscode.csharp");
if (!csharpExtension.isActive) {
await csharpExtension.activate();
let csharpExtension = vscode.extensions.getExtension("ms-vscode.csharp");
if (!csharpExtension.isActive) {
await csharpExtension.activate();
}

await csharpExtension.exports.initializationFinished;
await omnisharp.restart();
});

test("Hover returns structured documentation with proper newlines", async function () {

let program =
`using System;
namespace Test
{
class testissue
{
///<summary>Checks if object is tagged with the tag.</summary>
/// <param name="gameObject">The game object.</param>
/// <param name="tagName">Name of the tag.</param>
/// <returns>Returns <c>true</c> if object is tagged with tag.</returns>
public static bool Compare(int gameObject,string tagName)
{
return true;
}
}
}`;
let fileUri = await testAssetWorkspace.projects[0].addFileWithContents("test1.cs", program);

await omnisharp.waitForEmptyEventQueue();

await vscode.commands.executeCommand("vscode.open", fileUri);
});

let c = await vscode.commands.executeCommand("vscode.executeHoverProvider", fileUri,new vscode.Position(10,29));
test("Hover returns structured documentation with proper newlines", async function () {
let fileName = 'hover.cs';
let dir = path.dirname(testAssetWorkspace.projects[0].projectDirectoryPath);
let loc = path.join(dir, fileName);
let fileUri = vscode.Uri.file(loc);
await omnisharp.waitForEmptyEventQueue();

let answer:string =
`Checks if object is tagged with the tag.
await vscode.commands.executeCommand("vscode.open", fileUri);
let c = await vscode.commands.executeCommand("vscode.executeHoverProvider", fileUri, new vscode.Position(10, 29));
let answer: string =
`Checks if object is tagged with the tag.
Parameters:
\t\tgameObject: The game object.
\t\ttagName: Name of the tag.
Returns true if object is tagged with tag.`;
expect(c[0].contents[0].value).to.equal(answer);
expect(c[0].contents[0].value).to.equal(answer);
});

teardown(async () => {
await testAssetWorkspace.cleanupWorkspace();
});
Expand Down
16 changes: 16 additions & 0 deletions test/integrationTests/testAssets/singleCsproj/hover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
namespace Test
{
class testissue
{
///<summary>Checks if object is tagged with the tag.</summary>
/// <param name="gameObject">The game object.</param>
/// <param name="tagName">Name of the tag.</param>
/// <returns>Returns <c>true</c> if object is tagged with tag.</returns>

public static bool Compare(int gameObject,string tagName)
{
return true;
}
}
}
16 changes: 16 additions & 0 deletions test/integrationTests/testAssets/slnWithCsproj/src/app/hover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
namespace Test
{
class testissue
{
///<summary>Checks if object is tagged with the tag.</summary>
/// <param name="gameObject">The game object.</param>
/// <param name="tagName">Name of the tag.</param>
/// <returns>Returns <c>true</c> if object is tagged with tag.</returns>

public static bool Compare(int gameObject,string tagName)
{
return true;
}
}
}

0 comments on commit 8f178ab

Please sign in to comment.