mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-23 09:35:38 -05:00
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// 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.Tasks;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
using Moq;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
||||
{
|
||||
public static class ProtocolEndpointMocks
|
||||
{
|
||||
public static Mock<IProtocolEndpoint> AddEventHandling<TParams>(
|
||||
this Mock<IProtocolEndpoint> mock,
|
||||
EventType<TParams> expectedEvent,
|
||||
Action<EventType<TParams>, TParams> eventCallback)
|
||||
{
|
||||
var flow = mock.Setup(h => h.SendEvent(
|
||||
It.Is<EventType<TParams>>(m => m == expectedEvent),
|
||||
It.IsAny<TParams>()))
|
||||
.Returns(Task.FromResult(0));
|
||||
if (eventCallback != null)
|
||||
{
|
||||
flow.Callback(eventCallback);
|
||||
}
|
||||
|
||||
return mock;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,30 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
||||
};
|
||||
}
|
||||
|
||||
public static ServerInfo GetTestServerInfo()
|
||||
{
|
||||
return new ServerInfo()
|
||||
{
|
||||
ServerVersion = "14.0.1.0",
|
||||
ServerMajorVersion = 14,
|
||||
ServerMinorVersion = 0,
|
||||
EngineEditionId = 3,
|
||||
OsVersion = "Linux (Ubuntu 15.10)",
|
||||
IsCloud = false,
|
||||
ServerEdition = "Developer Edition",
|
||||
ServerLevel = ""
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a test sql connection factory instance
|
||||
/// </summary>
|
||||
public static ISqlConnectionFactory GetTestSqlConnectionFactory()
|
||||
{
|
||||
// use mock database connection
|
||||
return new TestSqlConnectionFactory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a test connection details object
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user