// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // #nullable disable 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 AddEventHandling( this Mock mock, EventType expectedEvent, Action, TParams> eventCallback) { var flow = mock.Setup(h => h.SendEvent( It.Is>(m => m == expectedEvent), It.IsAny())) .Returns(Task.FromResult(0)); if (eventCallback != null) { flow.Callback(eventCallback); } return mock; } } }