Files
sqltoolsservice/test/Microsoft.Kusto.ServiceLayer.UnitTests/LanguageServices/BindingQueueTests.cs
Karl Burtram f288bee294 Make nullable warnings a per file opt-in (#1842)
* Make nullable warnings a per file opt-in

* Remove unneeded compiler directives

* Remove compiler directive for User Data
2023-02-03 18:10:07 -08:00

52 lines
2.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.
//
#nullable disable
using System;
using System.Threading;
using Microsoft.Kusto.ServiceLayer.LanguageServices;
using Microsoft.Kusto.ServiceLayer.LanguageServices.Contracts;
using NUnit.Framework;
namespace Microsoft.Kusto.ServiceLayer.UnitTests.LanguageServices
{
public class BindingQueueTests
{
[Test]
public void QueueBindingOperation_Returns_Null_For_NullBindOperation()
{
var bindingQueue = new BindingQueue<ConnectedBindingContext>();
var queueItem = bindingQueue.QueueBindingOperation("", null);
Assert.IsNull(queueItem);
}
[Test]
public void QueueBindingOperation_Returns_QueueItem()
{
var key = "key";
var bindOperation = new Func<IBindingContext, CancellationToken, object>((context, token) => new Hover());
Func<IBindingContext, object> timeoutOperation = (context) => LanguageService.HoverTimeout;
Func<Exception, object> errorHandler = exception => new Exception();
var bindingTimeout = 30;
var waitForLockTimeout = 45;
var bindingQueue = new BindingQueue<ConnectedBindingContext>();
var queueItem = bindingQueue.QueueBindingOperation(key,
bindOperation,
timeoutOperation,
errorHandler,
bindingTimeout,
waitForLockTimeout);
Assert.AreEqual(key, queueItem.Key);
Assert.AreEqual(bindOperation, queueItem.BindOperation);
Assert.AreEqual(timeoutOperation, queueItem.TimeoutOperation);
Assert.AreEqual(errorHandler, queueItem.ErrorHandler);
Assert.AreEqual(bindingTimeout, queueItem.BindingTimeout);
Assert.AreEqual(waitForLockTimeout, queueItem.WaitForLockTimeout);
}
}
}