mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Ensure test file is deleted and fix test project path (#843)
* Ensure test file is always deleted * Fix up project path
This commit is contained in:
@@ -95,7 +95,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ManagedB
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ManagedBatchParser.IntegrationTests", "test\Microsoft.SqlTools.ManagedBatchParser.IntegrationTests\Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.csproj", "{D3696EFA-FB1E-4848-A726-FF7B168AFB96}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ManagedBatchParser.IntegrationTests", "test\Microsoft.SqlTools.ManagedBatchParser.IntegrationTests\Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.csproj", "{D3696EFA-FB1E-4848-A726-FF7B168AFB96}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.Test.CompletionExtension", "test\CompletionExtSample\Microsoft.SqlTools.Test.CompletionExtension.csproj", "{0EC2B30C-0652-49AE-9594-85B3C3E9CA21}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.Test.CompletionExtension", "test\Microsoft.SqlTools.Test.CompletionExtension\Microsoft.SqlTools.Test.CompletionExtension.csproj", "{0EC2B30C-0652-49AE-9594-85B3C3E9CA21}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<Import Project="../../Common.props" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\..\src\Microsoft.SqlTools.ServiceLayer\Microsoft.SqlTools.ServiceLayer.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -157,37 +157,42 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
|
|||||||
|
|
||||||
//Try to load the completion extension with new modified timestamp, expect a success
|
//Try to load the completion extension with new modified timestamp, expect a success
|
||||||
var assemblyCopyPath = CopyFileWithNewModifiedTime(extensionParams.AssemblyPath);
|
var assemblyCopyPath = CopyFileWithNewModifiedTime(extensionParams.AssemblyPath);
|
||||||
extensionParams = new CompletionExtensionParams()
|
try
|
||||||
{
|
{
|
||||||
AssemblyPath = assemblyCopyPath,
|
extensionParams = new CompletionExtensionParams()
|
||||||
TypeName = "Microsoft.SqlTools.Test.CompletionExtension.CompletionExt",
|
{
|
||||||
Properties = new Dictionary<string, object> { { "modelPath", "testModel" } }
|
AssemblyPath = assemblyCopyPath,
|
||||||
};
|
TypeName = "Microsoft.SqlTools.Test.CompletionExtension.CompletionExt",
|
||||||
//load and initialize completion extension
|
Properties = new Dictionary<string, object> { { "modelPath", "testModel" } }
|
||||||
await autoCompleteService.HandleCompletionExtLoadRequest(extensionParams, requestContext.Object);
|
};
|
||||||
|
//load and initialize completion extension
|
||||||
|
await autoCompleteService.HandleCompletionExtLoadRequest(extensionParams, requestContext.Object);
|
||||||
|
|
||||||
requestContext.Verify(x => x.SendResult(It.IsAny<bool>()), Times.Exactly(2));
|
requestContext.Verify(x => x.SendResult(It.IsAny<bool>()), Times.Exactly(2));
|
||||||
requestContext.Verify(x => x.SendError(It.IsAny<string>(), 0), Times.Once);
|
requestContext.Verify(x => x.SendError(It.IsAny<string>(), 0), Times.Once);
|
||||||
|
|
||||||
ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true };
|
ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true };
|
||||||
autoCompleteService.ParseAndBind(result.ScriptFile, result.ConnectionInfo);
|
autoCompleteService.ParseAndBind(result.ScriptFile, result.ConnectionInfo);
|
||||||
scriptInfo.ConnectionKey = autoCompleteService.BindingQueue.AddConnectionContext(result.ConnectionInfo);
|
scriptInfo.ConnectionKey = autoCompleteService.BindingQueue.AddConnectionContext(result.ConnectionInfo);
|
||||||
|
|
||||||
//Invoke auto completion with extension enabled
|
//Invoke auto completion with extension enabled
|
||||||
var completions = autoCompleteService.GetCompletionItems(
|
var completions = autoCompleteService.GetCompletionItems(
|
||||||
result.TextDocumentPosition,
|
result.TextDocumentPosition,
|
||||||
result.ScriptFile,
|
result.ScriptFile,
|
||||||
result.ConnectionInfo).Result;
|
result.ConnectionInfo).Result;
|
||||||
|
|
||||||
//Validate completion list is not empty
|
//Validate completion list is not empty
|
||||||
Assert.True(completions != null && completions.Length > 0, "The completion list is null or empty!");
|
Assert.True(completions != null && completions.Length > 0, "The completion list is null or empty!");
|
||||||
//Validate the first completion item in the list is preselected
|
//Validate the first completion item in the list is preselected
|
||||||
Assert.True(completions[0].Preselect.HasValue && completions[0].Preselect.Value, "Preselect is not set properly in the first completion item by the completion extension!");
|
Assert.True(completions[0].Preselect.HasValue && completions[0].Preselect.Value, "Preselect is not set properly in the first completion item by the completion extension!");
|
||||||
//Validate the Command object attached to the completion item by the extension
|
//Validate the Command object attached to the completion item by the extension
|
||||||
Assert.True(completions[0].Command != null && completions[0].Command.CommandStr == "vsintellicode.completionItemSelected", "Command is not set properly in the first completion item by the completion extension!");
|
Assert.True(completions[0].Command != null && completions[0].Command.CommandStr == "vsintellicode.completionItemSelected", "Command is not set properly in the first completion item by the completion extension!");
|
||||||
|
}
|
||||||
//clean up the temp file
|
finally
|
||||||
File.Delete(assemblyCopyPath);
|
{
|
||||||
|
//clean up the temp file
|
||||||
|
File.Delete(assemblyCopyPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -198,11 +203,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
|
|||||||
private string CopyFileWithNewModifiedTime(string filePath)
|
private string CopyFileWithNewModifiedTime(string filePath)
|
||||||
{
|
{
|
||||||
var tempPath = Path.Combine(Path.GetTempPath(), Path.GetFileName(filePath));
|
var tempPath = Path.Combine(Path.GetTempPath(), Path.GetFileName(filePath));
|
||||||
if (File.Exists(tempPath))
|
File.Copy(filePath, tempPath, overwrite: true);
|
||||||
{
|
|
||||||
File.Delete(tempPath);
|
|
||||||
}
|
|
||||||
File.Copy(filePath, tempPath);
|
|
||||||
File.SetLastWriteTimeUtc(tempPath, DateTime.UtcNow);
|
File.SetLastWriteTimeUtc(tempPath, DateTime.UtcNow);
|
||||||
return tempPath;
|
return tempPath;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<ProjectReference Include="../Microsoft.SqlTools.ServiceLayer.Test.Common/Microsoft.SqlTools.ServiceLayer.Test.Common.csproj" />
|
<ProjectReference Include="../Microsoft.SqlTools.ServiceLayer.Test.Common/Microsoft.SqlTools.ServiceLayer.Test.Common.csproj" />
|
||||||
<ProjectReference Include="../../src/Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.csproj" />
|
<ProjectReference Include="../../src/Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.csproj" />
|
||||||
<ProjectReference Include="../Microsoft.SqlTools.ServiceLayer.UnitTests/Microsoft.SqlTools.ServiceLayer.UnitTests.csproj" />
|
<ProjectReference Include="../Microsoft.SqlTools.ServiceLayer.UnitTests/Microsoft.SqlTools.ServiceLayer.UnitTests.csproj" />
|
||||||
<ProjectReference Include="..\CompletionExtSample\Microsoft.SqlTools.Test.CompletionExtension.csproj" />
|
<ProjectReference Include="../Microsoft.SqlTools.Test.CompletionExtension/Microsoft.SqlTools.Test.CompletionExtension.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="System.Net.Http" Version="4.3.1" />
|
<PackageReference Include="System.Net.Http" Version="4.3.1" />
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<Import Project="../../Common.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
|
<DebugType>portable</DebugType>
|
||||||
|
<AssemblyName>Microsoft.SqlTools.Test.CompletionExtension</AssemblyName>
|
||||||
|
<PackageId>Microsoft.SqlTools.Test.CompletionExtension</PackageId>
|
||||||
|
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||||
|
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="../../src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user