mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 09:59:48 -05:00
* Refactored Kusto.ServiceLayer to pass ConnectionDetails to DataSourceFactory instead of connection string. Created KustoConnectionDetails to map needed details to KustoClient. * Removed unused ScriptingScriptOperation from KustoServiceLayer. * Created DstsAuthenticationManager and moved logic for getting DstsToken. Updated error message for failing to create KustoConnection. * Removed DstsAuthenticationManager.cs. Refactored DataSourceFactory to retrieve UserToken from ConnectionDetails. * Renamed AzureAccountToken in ConnectionDetails to AccountToken. Changed mapping to KustoConnectionDetails based on the AccountToken. * Removed Kusto.Data reference from ConnectionService and ScriptingListObjectsOperation. Moved creation of KustoConnectionStringBuilder to DataSourceFactory * Added accountToken validation to DataSourceFactory Create. * Renamed KustoConnectionDetails to DataSourceConnectionDetails. Renamed AzureToken to AuthToken. * Refactored SchemaState and intellisense out of KustoClient to KustoIntellisenseClient. Added IIntellisenseClient. Added unit tests for KustoIntellisenseClient and KustoClient. * Removed unused property dataSourceFactory from LanguageService > InitializeService. Moved KustoIntellisense functions from KustoIntellisenseHelper to KustoIntellisenseClient and made SchemaState private. Added IIntellisenseClient to IDataSource. * Renamed directory from DataSourceIntellisense to Intellisense and updated namespace. Fixed namespace in ScriptDocumentInfo.
95 lines
3.6 KiB
C#
95 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Kusto.ServiceLayer.Connection.Contracts;
|
|
using Microsoft.Kusto.ServiceLayer.DataSource;
|
|
using Microsoft.Kusto.ServiceLayer.DataSource.Intellisense;
|
|
using Microsoft.Kusto.ServiceLayer.LanguageServices;
|
|
using Microsoft.Kusto.ServiceLayer.Workspace.Contracts;
|
|
using NUnit.Framework;
|
|
|
|
namespace Microsoft.Kusto.ServiceLayer.UnitTests.DataSource
|
|
{
|
|
public class DataSourceFactoryTests
|
|
{
|
|
[TestCase(typeof(ArgumentException), "ConnectionString", "AzureAccountToken")]
|
|
public void Create_Throws_Exceptions_For_InvalidParams(Type exceptionType,
|
|
string connectionString,
|
|
string azureAccountToken)
|
|
{
|
|
var dataSourceFactory = new DataSourceFactory();
|
|
var connectionDetails = new ConnectionDetails
|
|
{
|
|
ConnectionString = connectionString,
|
|
AccountToken = azureAccountToken
|
|
};
|
|
Assert.Throws(exceptionType,
|
|
() => dataSourceFactory.Create(DataSourceType.None, connectionDetails, ""));
|
|
}
|
|
|
|
[Test]
|
|
public void GetDefaultAutoComplete_Throws_ArgumentException_For_InvalidDataSourceType()
|
|
{
|
|
Assert.Throws<ArgumentException>(() =>
|
|
DataSourceFactory.GetDefaultAutoComplete(DataSourceType.None, null, null));
|
|
}
|
|
|
|
[Test]
|
|
public void GetDefaultAutoComplete_Returns_CompletionItems()
|
|
{
|
|
var textDocumentPosition = new TextDocumentPosition
|
|
{
|
|
Position = new Position()
|
|
};
|
|
var scriptFile = new ScriptFile("", "", "");
|
|
var scriptParseInfo = new ScriptParseInfo();
|
|
var documentInfo = new ScriptDocumentInfo(textDocumentPosition, scriptFile, scriptParseInfo);
|
|
var position = new Position();
|
|
|
|
var completionItems = DataSourceFactory.GetDefaultAutoComplete(DataSourceType.Kusto, documentInfo, position);
|
|
Assert.AreNotEqual(0, completionItems.Length);
|
|
}
|
|
|
|
[Test]
|
|
public void GetDefaultSemanticMarkers_Throws_ArgumentException_For_InvalidDataSourceType()
|
|
{
|
|
Assert.Throws<ArgumentException>(() =>
|
|
DataSourceFactory.GetDefaultSemanticMarkers(DataSourceType.None, null, null, null));
|
|
}
|
|
|
|
[Test]
|
|
public void GetDefaultSemanticMarkers_Returns_ScriptFileMarker()
|
|
{
|
|
var parseInfo = new ScriptParseInfo();
|
|
var file = new ScriptFile("", "", "");
|
|
var queryText = ".show databases";
|
|
|
|
var semanticMarkers = DataSourceFactory.GetDefaultSemanticMarkers(DataSourceType.Kusto, parseInfo, file, queryText);
|
|
|
|
Assert.AreEqual(0, semanticMarkers.Length);
|
|
}
|
|
|
|
[Test]
|
|
public void ConvertToServerInfoFormat_Throws_ArgumentException_For_InvalidDataSourceType()
|
|
{
|
|
Assert.Throws<ArgumentException>(() =>
|
|
DataSourceFactory.ConvertToServerInfoFormat(DataSourceType.None, null));
|
|
}
|
|
|
|
[Test]
|
|
public void ConvertToServerInfoFormat_Returns_ServerInfo_With_Options()
|
|
{
|
|
var diagnosticsInfo = new DiagnosticsInfo
|
|
{
|
|
Options = new Dictionary<string, object>
|
|
{
|
|
{"Key", "Object"}
|
|
}
|
|
};
|
|
|
|
var serverInfo = DataSourceFactory.ConvertToServerInfoFormat(DataSourceType.Kusto, diagnosticsInfo);
|
|
|
|
Assert.IsNotNull(serverInfo.Options);
|
|
Assert.AreEqual(diagnosticsInfo.Options["Key"], serverInfo.Options["Key"]);
|
|
}
|
|
}
|
|
} |