mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 09:59:48 -05:00
* Fix to make sql exceptions surface properly to user (with important notes!) * Adding support for detecting column size issues when updating a cell * Adding unit tests for the exception on read scenario
82 lines
3.0 KiB
C#
82 lines
3.0 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.SqlTools.Extensibility;
|
|
using Microsoft.SqlTools.ResourceProvider.Core;
|
|
using Microsoft.SqlTools.ResourceProvider.Core.Extensibility;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Fakes
|
|
{
|
|
/// <summary>
|
|
/// A fake database discovery class which generates db names for 5 seconds or until it gets canceled
|
|
/// </summary>
|
|
public class FakeDatabaseDiscoveryProvider : IDatabaseDiscoveryProvider
|
|
{
|
|
private TimeSpan _timeout = TimeSpan.FromSeconds(5);
|
|
|
|
public IExportableMetadata Metadata { get; set; }
|
|
public ExportableStatus Status { get; }
|
|
IExportableMetadata IExportable.Metadata
|
|
{
|
|
get { throw new NotImplementedException(); }
|
|
set { throw new NotImplementedException(); }
|
|
}
|
|
|
|
ExportableStatus IExportable.Status
|
|
{
|
|
get { throw new NotImplementedException(); }
|
|
}
|
|
|
|
public Task<ServiceResponse<DatabaseInstanceInfo>> GetDatabaseInstancesAsync(string serverName, CancellationToken cancellationToken)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
//public Task<ServiceResponse<DatabaseInstanceInfo>> GetDatabaseInstancesAsync(UIConnectionInfo uiConnectionInfo, CancellationToken cancellationToken)
|
|
//{
|
|
// return Task.Factory.StartNew(() => GetDatabaseInstances(uiConnectionInfo, cancellationToken), cancellationToken);
|
|
//}
|
|
|
|
//private ServiceResponse<DatabaseInstanceInfo> GetDatabaseInstances(UIConnectionInfo uiConnectionInfo, CancellationToken cancellationToken)
|
|
//{
|
|
// List<DatabaseInstanceInfo> databases = new List<DatabaseInstanceInfo>();
|
|
// DateTime startTime = DateTime.UtcNow;
|
|
// while (!cancellationToken.IsCancellationRequested)
|
|
// {
|
|
// DateTime now = DateTime.UtcNow;
|
|
// if (now.Subtract(startTime).TotalMilliseconds >= _timeout.TotalMilliseconds)
|
|
// {
|
|
// break;
|
|
// }
|
|
// databases.Add(new DatabaseInstanceInfo(ServerDefinition.Default, uiConnectionInfo.ServerName, uiConnectionInfo.ServerName + "" + Guid.NewGuid().ToString()));
|
|
// }
|
|
|
|
// return new ServiceResponse<DatabaseInstanceInfo>(databases);
|
|
//}
|
|
|
|
private static void TimerCallback(object state)
|
|
{
|
|
|
|
}
|
|
|
|
private void OnDatabaseFound(DatabaseInstanceInfo databaseInfo)
|
|
{
|
|
if (DatabaseFound != null)
|
|
{
|
|
DatabaseFound(this, new DatabaseInfoEventArgs() { Database = databaseInfo });
|
|
}
|
|
}
|
|
|
|
public void SetServiceProvider(IMultiServiceProvider provider)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public event EventHandler<DatabaseInfoEventArgs> DatabaseFound;
|
|
}
|
|
}
|