mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-14 03:58:35 -05:00
3278 Kusto Unit Test Refactor (#1053)
* 3278 Moved functions related to Metadata from DataSourceFactory to MetadataFactory.cs * 3278 Refactored DataSourceFactory to not be static. Added IDataSourceFactory interface. * 3278 Refactored IKustoIntellisenseHelper.cs to not be static. Added IKustoIntellisenseHelper.cs interface. * 3278 Removed unused functions from Scripter and deleted ScripterCore.cs because it was unused. Refactored Scripter.cs methods to not be static and created IScripter.cs * 3278 Refactored datsasourceConnectionFactory in ConnectionService to use MEF through the InitializeService function * 3278 Refactored IAutoCompleteHelper to not be static and added IAutoCompleteHelper interface. * 3278 Removed unused classes DatabaseFullAccessException and FeatureWithFullDbAccess. Refactored ObjectExplorerService to use ImportingConstructor attribute. Removed commented out in KustoResultsReader. Removed unused functions from DatabaseLocksManager. Removed unused IDataSourceConnectionFactory from ConnectionService * 3278 Moved SqlConnectionOpener class to new file. Added new interfaces IConnectedBindingQueue.cs and ISqlConnectionOpener.cs Added sqlConnectionOpener to dependency in ConnectedBindingQueue. * 3278 Removed needsMetadata param from ConnectedBindingQueue. Added param to AddConnectionContext where it's used * 3278 Refactored ConnectedBindingQueue to use MEF. Refactored usages to run against interface. * 3278 Corrected ServiceHost namespace. Removed unused dependency to sqlToolsContext in LanguageService. Updated dependency in MetadataService and LanguageService to IProtocolEndpoint instead of ServiceHost * 3278 Added back NextResult function and summary to KustoResultsReader. Renamed instance to _instance in ConnectionService and DatabaseLocksManager to stay consistent. Changed OpenDataSourceConnection to private in ConnectionService * 3278 Converted helper methods back to static and removed backing interfaces * 3278 Reverted AdminService > InitializeService to use ServiceHost as param
This commit is contained in:
@@ -12,7 +12,6 @@ using Microsoft.Kusto.ServiceLayer.Admin.Contracts;
|
||||
using Microsoft.Kusto.ServiceLayer.Connection;
|
||||
using Microsoft.Kusto.ServiceLayer.DataSource;
|
||||
using Microsoft.Kusto.ServiceLayer.DataSource.Metadata;
|
||||
using Microsoft.Kusto.ServiceLayer.Hosting;
|
||||
using Microsoft.Kusto.ServiceLayer.Utility;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Admin
|
||||
@@ -26,13 +25,6 @@ namespace Microsoft.Kusto.ServiceLayer.Admin
|
||||
|
||||
private static ConnectionService connectionService = null;
|
||||
|
||||
/// <summary>
|
||||
/// Default, parameterless constructor.
|
||||
/// </summary>
|
||||
internal AdminService()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal for testing purposes only
|
||||
/// </summary>
|
||||
@@ -72,7 +64,7 @@ namespace Microsoft.Kusto.ServiceLayer.Admin
|
||||
/// <summary>
|
||||
/// Handle get database info request
|
||||
/// </summary>
|
||||
internal static async Task HandleGetDatabaseInfoRequest(
|
||||
internal async Task HandleGetDatabaseInfoRequest(
|
||||
GetDatabaseInfoParams databaseParams,
|
||||
RequestContext<GetDatabaseInfoResponse> requestContext)
|
||||
{
|
||||
@@ -114,18 +106,18 @@ namespace Microsoft.Kusto.ServiceLayer.Admin
|
||||
/// </summary>
|
||||
/// <param name="connInfo"></param>
|
||||
/// <returns></returns>
|
||||
internal static DatabaseInfo GetDatabaseInfo(ConnectionInfo connInfo)
|
||||
internal DatabaseInfo GetDatabaseInfo(ConnectionInfo connInfo)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(connInfo.ConnectionDetails.DatabaseName)){
|
||||
ReliableDataSourceConnection connection;
|
||||
connInfo.TryGetConnection("Default", out connection);
|
||||
IDataSource dataSource = connection.GetUnderlyingConnection();
|
||||
DataSourceObjectMetadata objectMetadata = DataSourceFactory.CreateClusterMetadata(connInfo.ConnectionDetails.ServerName);
|
||||
DataSourceObjectMetadata objectMetadata = MetadataFactory.CreateClusterMetadata(connInfo.ConnectionDetails.ServerName);
|
||||
|
||||
List<DataSourceObjectMetadata> metadata = dataSource.GetChildObjects(objectMetadata, true).ToList();
|
||||
var databaseMetadata = metadata.Where(o => o.Name == connInfo.ConnectionDetails.DatabaseName);
|
||||
|
||||
List<DatabaseInfo> databaseInfo = DataSourceFactory.ConvertToDatabaseInfo(databaseMetadata);
|
||||
List<DatabaseInfo> databaseInfo = MetadataFactory.ConvertToDatabaseInfo(databaseMetadata);
|
||||
|
||||
return databaseInfo.ElementAtOrDefault(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user