mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 09:59:48 -05:00
The main change in this pull request is to add a new event that will be fired upon completion of a resultset but before the completion of a batch. This event will only fire if a resultset is available and generated. Changes: * ConnectionService - Slight changes to enable mocking, cleanup * Batch - Moving summary generation into ResultSet class, adding generation of ordinals for resultset and locking of result set list (which needs further refinement, but would be outside scope of this change) * Adding new event and associated parameters for completion of a resultset. Params return the resultset summary * Adding logic for assigning the event a handler in the query execution service * Adding unit tests for testing the new event /making sure the existing tests work * Refactoring some private properties into member variables * Refactor to remove SectionData class in favor of BufferRange * Adding callback for batch completion that will let the extension know that a batch has completed execution * Refactoring to make progressive results work as per async query execution * Allowing retrieval of batch results while query is in progress * reverting global.json, whoops * Adding a few missing comments, and fixing a couple code style bugs * Using SelectionData everywhere again * One more missing comment * Adding new notification type for result set completion * Plumbing event for result set completion * Unit tests for result set events This includes a fairly substantial change to create a mock of the ConnectionService and to create separate memorystream storage arrays. It preserves more correct behavior with a integration test, fixes an issue where the test db reader will return n-1 rows because the Reliable Connection Helper steals a record. * Adding locking to ResultSets for thread safety * Adding/fixing unit tests * Adding batch ID to result set summary
43 lines
1.5 KiB
C#
43 lines
1.5 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.Reflection;
|
|
using Moq.Language;
|
|
using Moq.Language.Flow;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.Test.Utility
|
|
{
|
|
public static class MoqExtensions
|
|
{
|
|
public delegate void OutAction<TOut>(out TOut outVal);
|
|
|
|
public delegate void OutAction<in T1, TOut>(T1 arg1, out TOut outVal);
|
|
|
|
public static IReturnsThrows<TMock, TReturn> OutCallback<TMock, TReturn, TOut>(
|
|
this ICallback<TMock, TReturn> mock, OutAction<TOut> action) where TMock : class
|
|
{
|
|
return OutCallbackInternal(mock, action);
|
|
}
|
|
|
|
public static IReturnsThrows<TMock, TReturn> OutCallback<TMock, TReturn, T1, TOut>(
|
|
this ICallback<TMock, TReturn> mock, OutAction<T1, TOut> action) where TMock : class
|
|
{
|
|
return OutCallbackInternal(mock, action);
|
|
}
|
|
|
|
private static IReturnsThrows<TMock, TReturn> OutCallbackInternal<TMock, TReturn>(
|
|
ICallback<TMock, TReturn> mock, object action) where TMock : class
|
|
{
|
|
typeof(ICallback<TMock, TReturn>).GetTypeInfo()
|
|
.Assembly.GetType("Moq.MethodCall")
|
|
.GetMethod("SetCallbackWithArguments",
|
|
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance)
|
|
.Invoke(mock, new[] { action });
|
|
return mock as IReturnsThrows<TMock, TReturn>;
|
|
|
|
}
|
|
}
|
|
}
|