Adding missing nuget references for SqlProjects functionality (#1827)

* Adding test messages

* Adding file system globbing reference

* fixing string

* fixing string again

* Sigh
This commit is contained in:
Benjin Dubishar
2023-01-27 15:18:40 -08:00
committed by GitHub
parent 251fbf8746
commit 82171740bc
4 changed files with 48 additions and 32 deletions

View File

@@ -7,7 +7,9 @@ using System;
using System.Threading.Tasks;
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking
{
@@ -61,7 +63,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking
}
}
public class MockRequest<T>
public class MockRequest<T> where T : ResultStatus
{
private T? result;
public T Result => result ?? throw new InvalidOperationException("No result has been sent for the request");
@@ -73,5 +75,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking
{
Mock = RequestContextMocks.Create<T>(actual => result = actual);
}
/// <summary>
/// Asserts that this request was successful
/// </summary>
/// <param name="handlerName">Name of the handler, recommended to use nameof(service.MyHandler), used in the failure message</param>
/// <param name="descriptor">Optional extra descriptor, parenthesized in the failure message</param>
public void AssertSuccess(string handlerName, string? descriptor = null)
{
Assert.IsTrue(this.Result.Success, $"{handlerName}{(descriptor != null ? $" ({descriptor})" : String.Empty)} expected to succeed, but failed with error: '{this.Result.ErrorMessage}'");
}
}
}