Adding getters for project items in SqlProject service (#1879)

* Adding getters for project items

* updated comment
This commit is contained in:
Benjin Dubishar
2023-02-23 16:25:01 -08:00
committed by GitHub
parent 6cf5147eaf
commit f7fd478857
8 changed files with 341 additions and 9 deletions

View File

@@ -0,0 +1,39 @@
//
// 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 Microsoft.SqlServer.Dac.Projects;
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.SqlProjects.Contracts
{
public class GetDatabaseReferencesRequest
{
public static readonly RequestType<SqlProjectParams, GetDatabaseReferencesResult> Type = RequestType<SqlProjectParams, GetDatabaseReferencesResult>.Create("sqlProjects/getDatabaseReferences");
}
/// <summary>
/// Result containing database references in the project
/// </summary>
public class GetDatabaseReferencesResult : ResultStatus
{
/// <summary>
/// Array of system database references contained in the project
/// </summary>
public SystemDatabaseReference[] SystemDatabaseReferences { get; set; }
/// <summary>
/// Array of dacpac references contained in the project
/// </summary>
public DacpacReference[] DacpacReferences { get; set; }
/// <summary>
/// Array of SQL project references contained in the project
/// </summary>
public SqlProjectReference[] SqlProjectReferences { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
//
// 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 Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.SqlProjects.Contracts
{
public class GetFoldersRequest
{
public static readonly RequestType<SqlProjectParams, GetFoldersResult> Type = RequestType<SqlProjectParams, GetFoldersResult>.Create("sqlProjects/getFolders");
}
/// <summary>
/// Result containing folders in the project
/// </summary>
public class GetFoldersResult : ResultStatus
{
/// <summary>
/// Array of folders contained in the project
/// </summary>
public string[] Folders { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
//
// 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 Microsoft.SqlTools.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.SqlProjects.Contracts
{
public class GetPostDeploymentScriptsRequest
{
public static readonly RequestType<SqlProjectParams, GetScriptsResult> Type = RequestType<SqlProjectParams, GetScriptsResult>.Create("sqlProjects/getPostDeploymentScripts");
}
}

View File

@@ -0,0 +1,16 @@
//
// 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 Microsoft.SqlTools.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.SqlProjects.Contracts
{
public class GetPreDeploymentScriptsRequest
{
public static readonly RequestType<SqlProjectParams, GetScriptsResult> Type = RequestType<SqlProjectParams, GetScriptsResult>.Create("sqlProjects/getPreDeploymentScripts");
}
}

View File

@@ -0,0 +1,29 @@
//
// 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 Microsoft.SqlServer.Dac.Projects;
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.SqlProjects.Contracts
{
public class GetSqlCmdVariablesRequest
{
public static readonly RequestType<SqlProjectParams, GetSqlCmdVariablesResult> Type = RequestType<SqlProjectParams, GetSqlCmdVariablesResult>.Create("sqlProjects/getSqlCmdVariables");
}
/// <summary>
/// Result containing SQLCMD variables in the project
/// </summary>
public class GetSqlCmdVariablesResult : ResultStatus
{
/// <summary>
/// Array of SQLCMD variables contained in the project
/// </summary>
public SqlCmdVariable[] SqlCmdVariables { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
//
// 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 Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.SqlProjects.Contracts
{
public class GetSqlObjectScriptsRequest
{
public static readonly RequestType<SqlProjectParams, GetScriptsResult> Type = RequestType<SqlProjectParams, GetScriptsResult>.Create("sqlProjects/getSqlObjectScripts");
}
/// <summary>
/// Result containing scripts in the project
/// </summary>
public class GetScriptsResult : ResultStatus
{
/// <summary>
/// Array of scripts contained in the project
/// </summary>
public string[] Scripts { get; set; }
}
}

View File

@@ -5,6 +5,7 @@
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.SqlServer.Dac.Projects;
using Microsoft.SqlTools.Hosting.Protocol;
@@ -47,32 +48,38 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
serviceHost.SetRequestHandler(UpdateProjectForCrossPlatformRequest.Type, HandleUpdateProjectForCrossPlatformRequest, isParallelProcessingSupported: false);
// SQL object script functions
serviceHost.SetRequestHandler(GetSqlObjectScriptsRequest.Type, HandleGetSqlObjectScriptsRequest, isParallelProcessingSupported: true);
serviceHost.SetRequestHandler(AddSqlObjectScriptRequest.Type, HandleAddSqlObjectScriptRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(DeleteSqlObjectScriptRequest.Type, HandleDeleteSqlObjectScriptRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(ExcludeSqlObjectScriptRequest.Type, HandleExcludeSqlObjectScriptRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(MoveSqlObjectScriptRequest.Type, HandleMoveSqlObjectScriptRequest, isParallelProcessingSupported: false);
// Pre/Post-deployment script functions
serviceHost.SetRequestHandler(GetPreDeploymentScriptsRequest.Type, HandleGetPreDeploymentScriptsRequest, isParallelProcessingSupported: true);
serviceHost.SetRequestHandler(AddPreDeploymentScriptRequest.Type, HandleAddPreDeploymentScriptRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(DeletePreDeploymentScriptRequest.Type, HandleDeletePreDeploymentScriptRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(ExcludePreDeploymentScriptRequest.Type, HandleExcludePreDeploymentScriptRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(MovePreDeploymentScriptRequest.Type, HandleMovePreDeploymentScriptRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(GetPostDeploymentScriptsRequest.Type, HandleGetPostDeploymentScriptsRequest, isParallelProcessingSupported: true);
serviceHost.SetRequestHandler(AddPostDeploymentScriptRequest.Type, HandleAddPostDeploymentScriptRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(DeletePostDeploymentScriptRequest.Type, HandleDeletePostDeploymentScriptRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(ExcludePostDeploymentScriptRequest.Type, HandleExcludePostDeploymentScriptRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(MovePostDeploymentScriptRequest.Type, HandleMovePostDeploymentScriptRequest, isParallelProcessingSupported: false);
// Folder functions
serviceHost.SetRequestHandler(GetFoldersRequest.Type, HandleGetFoldersRequest, isParallelProcessingSupported: true);
serviceHost.SetRequestHandler(AddFolderRequest.Type, HandleAddFolderRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(DeleteFolderRequest.Type, HandleDeleteFolderRequest, isParallelProcessingSupported: false);
// SQLCMD variable functions
serviceHost.SetRequestHandler(GetSqlCmdVariablesRequest.Type, HandleGetSqlCmdVariablesRequest, isParallelProcessingSupported: true);
serviceHost.SetRequestHandler(AddSqlCmdVariableRequest.Type, HandleAddSqlCmdVariableRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(DeleteSqlCmdVariableRequest.Type, HandleDeleteSqlCmdVariableRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(UpdateSqlCmdVariableRequest.Type, HandleUpdateSqlCmdVariableRequest, isParallelProcessingSupported: false);
// Database reference functions
serviceHost.SetRequestHandler(GetDatabaseReferencesRequest.Type, HandleGetDatabaseReferencesRequest, isParallelProcessingSupported: true);
serviceHost.SetRequestHandler(AddSystemDatabaseReferenceRequest.Type, HandleAddSystemDatabaseReferenceRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(AddDacpacReferenceRequest.Type, HandleAddDacpacReferenceRequest, isParallelProcessingSupported: false);
serviceHost.SetRequestHandler(AddSqlProjectReferenceRequest.Type, HandleAddSqlProjectReferenceRequest, isParallelProcessingSupported: false);
@@ -109,14 +116,14 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
{
Success = true,
ErrorMessage = null,
IsCrossPlatformCompatible = GetProject(requestParams.ProjectUri!).CrossPlatformCompatible
IsCrossPlatformCompatible = GetProject(requestParams.ProjectUri).CrossPlatformCompatible
};
}, requestContext);
}
internal async Task HandleUpdateProjectForCrossPlatformRequest(SqlProjectParams requestParams, RequestContext<ResultStatus> requestContext)
{
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri!).UpdateForCrossPlatform(), requestContext);
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri).UpdateForCrossPlatform(), requestContext);
}
#endregion
@@ -125,19 +132,32 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
#region SQL object script functions
internal async Task HandleGetSqlObjectScriptsRequest(SqlProjectParams requestParams, RequestContext<GetScriptsResult> requestContext)
{
await RunWithErrorHandling(() =>
{
return new GetScriptsResult()
{
Success = true,
ErrorMessage = null,
Scripts = GetProject(requestParams.ProjectUri).SqlObjectScripts.Select(x => x.Path).ToArray()
};
}, requestContext);
}
internal async Task HandleAddSqlObjectScriptRequest(SqlProjectScriptParams requestParams, RequestContext<ResultStatus> requestContext)
{
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri!).SqlObjectScripts.Add(new SqlObjectScript(requestParams.Path!)), requestContext);
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri).SqlObjectScripts.Add(new SqlObjectScript(requestParams.Path!)), requestContext);
}
internal async Task HandleDeleteSqlObjectScriptRequest(SqlProjectScriptParams requestParams, RequestContext<ResultStatus> requestContext)
{
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri!).SqlObjectScripts.Delete(requestParams.Path!), requestContext);
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri).SqlObjectScripts.Delete(requestParams.Path!), requestContext);
}
internal async Task HandleExcludeSqlObjectScriptRequest(SqlProjectScriptParams requestParams, RequestContext<ResultStatus> requestContext)
{
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri!).SqlObjectScripts.Exclude(requestParams.Path!), requestContext);
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri).SqlObjectScripts.Exclude(requestParams.Path!), requestContext);
}
internal async Task HandleMoveSqlObjectScriptRequest(MoveItemParams requestParams, RequestContext<ResultStatus> requestContext)
@@ -149,6 +169,19 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
#region Pre/Post-deployment script functions
internal async Task HandleGetPreDeploymentScriptsRequest(SqlProjectParams requestParams, RequestContext<GetScriptsResult> requestContext)
{
await RunWithErrorHandling(() =>
{
return new GetScriptsResult()
{
Success = true,
ErrorMessage = null,
Scripts = GetProject(requestParams.ProjectUri).PreDeployScripts.Select(x => x.Path).ToArray()
};
}, requestContext);
}
internal async Task HandleAddPreDeploymentScriptRequest(SqlProjectScriptParams requestParams, RequestContext<ResultStatus> requestContext)
{
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri).PreDeployScripts.Add(new PreDeployScript(requestParams.Path)), requestContext);
@@ -169,6 +202,19 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri).PreDeployScripts.Move(requestParams.Path, requestParams.DestinationPath), requestContext);
}
internal async Task HandleGetPostDeploymentScriptsRequest(SqlProjectParams requestParams, RequestContext<GetScriptsResult> requestContext)
{
await RunWithErrorHandling(() =>
{
return new GetScriptsResult()
{
Success = true,
ErrorMessage = null,
Scripts = GetProject(requestParams.ProjectUri).PostDeployScripts.Select(x => x.Path).ToArray()
};
}, requestContext);
}
internal async Task HandleAddPostDeploymentScriptRequest(SqlProjectScriptParams requestParams, RequestContext<ResultStatus> requestContext)
{
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri).PostDeployScripts.Add(new PostDeployScript(requestParams.Path)), requestContext);
@@ -193,6 +239,19 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
#region Folder functions
internal async Task HandleGetFoldersRequest(SqlProjectParams requestParams, RequestContext<GetFoldersResult> requestContext)
{
await RunWithErrorHandling(() =>
{
return new GetFoldersResult()
{
Success = true,
ErrorMessage = null,
Folders = GetProject(requestParams.ProjectUri).Folders.Select(x => x.Path).ToArray()
};
}, requestContext);
}
internal async Task HandleAddFolderRequest(FolderParams requestParams, RequestContext<ResultStatus> requestContext)
{
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri).Folders.Add(new Folder(requestParams.Path)), requestContext);
@@ -209,6 +268,21 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
#region Database Reference functions
internal async Task HandleGetDatabaseReferencesRequest(SqlProjectParams requestParams, RequestContext<GetDatabaseReferencesResult> requestContext)
{
await RunWithErrorHandling(() =>
{
return new GetDatabaseReferencesResult()
{
Success = true,
ErrorMessage = null,
SystemDatabaseReferences = GetProject(requestParams.ProjectUri).DatabaseReferences.OfType<SystemDatabaseReference>().ToArray(),
DacpacReferences = GetProject(requestParams.ProjectUri).DatabaseReferences.OfType<DacpacReference>().ToArray(),
SqlProjectReferences = GetProject(requestParams.ProjectUri).DatabaseReferences.OfType<SqlProjectReference>().ToArray()
};
}, requestContext);
}
internal async Task HandleAddSystemDatabaseReferenceRequest(AddSystemDatabaseReferenceParams requestParams, RequestContext<ResultStatus> requestContext)
{
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri!).DatabaseReferences.Add(
@@ -299,6 +373,19 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
#region SQLCMD variable functions
internal async Task HandleGetSqlCmdVariablesRequest(SqlProjectParams requestParams, RequestContext<GetSqlCmdVariablesResult> requestContext)
{
await RunWithErrorHandling(() =>
{
return new GetSqlCmdVariablesResult()
{
Success = true,
ErrorMessage = null,
SqlCmdVariables = GetProject(requestParams.ProjectUri).SqlCmdVariables.ToArray()
};
}, requestContext);
}
internal async Task HandleAddSqlCmdVariableRequest(AddSqlCmdVariableParams requestParams, RequestContext<ResultStatus> requestContext)
{
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri!).SqlCmdVariables.Add(new SqlCmdVariable(requestParams.Name, requestParams.DefaultValue, requestParams.Value)), requestContext);

View File

@@ -101,7 +101,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlProjects
}
[Test]
public async Task TestSqlObjectScriptAddDeleteExcludeMove()
public async Task TestSqlObjectScriptOperations()
{
// Setup
SqlProjectsService service = new();
@@ -125,6 +125,17 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlProjects
Assert.AreEqual(1, service.Projects[projectUri].SqlObjectScripts.Count, "SqlObjectScripts count after add");
Assert.IsTrue(service.Projects[projectUri].SqlObjectScripts.Contains(scriptRelativePath), $"SqlObjectScripts expected to contain {scriptRelativePath}");
// Validate getting a list of the SQL object scripts
MockRequest<GetScriptsResult> getMock = new();
await service.HandleGetSqlObjectScriptsRequest(new SqlProjectParams()
{
ProjectUri = projectUri
}, getMock.Object);
getMock.AssertSuccess(nameof(service.HandleGetSqlObjectScriptsRequest));
Assert.AreEqual(1, getMock.Result.Scripts.Length);
Assert.AreEqual(scriptRelativePath, getMock.Result.Scripts[0]);
// Validate excluding a SQL object script
requestMock = new();
await service.HandleExcludeSqlObjectScriptRequest(new SqlProjectScriptParams()
@@ -179,7 +190,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlProjects
}
[Test]
public async Task TestPreDeploymentScriptAddDeleteExcludeMove()
public async Task TestPreDeploymentScriptOperations()
{
// Setup
SqlProjectsService service = new();
@@ -203,6 +214,17 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlProjects
Assert.AreEqual(1, service.Projects[projectUri].PreDeployScripts.Count, "PreDeployScript count after add");
Assert.IsTrue(service.Projects[projectUri].PreDeployScripts.Contains(scriptRelativePath), $"PreDeployScripts expected to contain {scriptRelativePath}");
// Validate getting a list of the pre-deployment scripts
MockRequest<GetScriptsResult> getMock = new();
await service.HandleGetPreDeploymentScriptsRequest(new SqlProjectParams()
{
ProjectUri = projectUri
}, getMock.Object);
getMock.AssertSuccess(nameof(service.HandleGetPreDeploymentScriptsRequest));
Assert.AreEqual(1, getMock.Result.Scripts.Length);
Assert.AreEqual(scriptRelativePath, getMock.Result.Scripts[0]);
// Validate excluding a pre-deployment script
requestMock = new();
await service.HandleExcludePreDeploymentScriptRequest(new SqlProjectScriptParams()
@@ -281,6 +303,17 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlProjects
Assert.AreEqual(1, service.Projects[projectUri].PostDeployScripts.Count, "PostDeployScript count after add");
Assert.IsTrue(service.Projects[projectUri].PostDeployScripts.Contains(scriptRelativePath), $"PostDeployScripts expected to contain {scriptRelativePath}");
// Validate getting a list of the post-deployment scripts
MockRequest<GetScriptsResult> getMock = new();
await service.HandleGetPostDeploymentScriptsRequest(new SqlProjectParams()
{
ProjectUri = projectUri
}, getMock.Object);
getMock.AssertSuccess(nameof(service.HandleGetPostDeploymentScriptsRequest));
Assert.AreEqual(1, getMock.Result.Scripts.Length);
Assert.AreEqual(scriptRelativePath, getMock.Result.Scripts[0]);
// Validate excluding a Post-deployment script
requestMock = new();
await service.HandleExcludePostDeploymentScriptRequest(new SqlProjectScriptParams()
@@ -336,6 +369,40 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlProjects
#region Database reference tests
[Test]
public async Task TestGetDatabaseReferences()
{
var (service, projectUri, _, _) = await SetUpDatabaseReferenceTest();
// directly add some database references
SystemDatabaseReference systemDatabaseReference = new SystemDatabaseReference(SystemDatabase.MSDB, suppressMissingDependencies: true);
DacpacReference dacpacReference = new DacpacReference("OtherDatabaseDacpac.dacpac", suppressMissingDependencies: true);
SqlProjectReference sqlProjectReference = new SqlProjectReference("OtherDatabaseProject.sqlproj", projectGuid: TEST_GUID, suppressMissingDependencies: true);
service.Projects[projectUri].DatabaseReferences.Add(systemDatabaseReference);
service.Projects[projectUri].DatabaseReferences.Add(dacpacReference);
service.Projects[projectUri].DatabaseReferences.Add(sqlProjectReference);
// Validate getting a list of the post-deployment scripts
MockRequest<GetDatabaseReferencesResult> getMock = new();
await service.HandleGetDatabaseReferencesRequest(new SqlProjectParams()
{
ProjectUri = projectUri
}, getMock.Object);
getMock.AssertSuccess(nameof(service.HandleGetDatabaseReferencesRequest));
Assert.AreEqual(1, getMock.Result.SystemDatabaseReferences.Length);
Assert.AreEqual(systemDatabaseReference, getMock.Result.SystemDatabaseReferences[0]);
Assert.AreEqual(1, getMock.Result.DacpacReferences.Length);
Assert.AreEqual(dacpacReference, getMock.Result.DacpacReferences[0]);
Assert.AreEqual(1, getMock.Result.SqlProjectReferences.Length);
Assert.AreEqual(sqlProjectReference, getMock.Result.SqlProjectReferences[0]);
}
[Test]
public async Task TestDatabaseReferenceDelete()
{
@@ -516,7 +583,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlProjects
#endregion
[Test]
public async Task TestFolderAddDelete()
public async Task TestFolderOperations()
{
// Setup
SqlProjectsService service = new();
@@ -538,6 +605,17 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlProjects
Assert.IsTrue(Directory.Exists(Path.Join(Path.GetDirectoryName(projectUri), folderParams.Path)), $"Subfolder '{folderParams.Path}' expected to exist on disk");
Assert.IsTrue(service.Projects[projectUri].Folders.Contains(folderParams.Path), $"SqlObjectScripts expected to contain {folderParams.Path}");
// Validate getting a list of the post-deployment scripts
MockRequest<GetFoldersResult> getMock = new();
await service.HandleGetFoldersRequest(new SqlProjectParams()
{
ProjectUri = projectUri
}, getMock.Object);
getMock.AssertSuccess(nameof(service.HandleGetFoldersRequest));
Assert.AreEqual(1, getMock.Result.Folders.Length);
Assert.AreEqual(folderParams.Path, getMock.Result.Folders[0]);
// Validate deleting a folder
requestMock = new();
await service.HandleDeleteFolderRequest(folderParams, requestMock.Object);
@@ -547,7 +625,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlProjects
}
[Test]
public async Task TestSqlCmdVariablesAddDelete()
public async Task TestSqlCmdVariablesOperations()
{
SqlProjectsService service = new();
string projectUri = await service.CreateSqlProject();
@@ -571,6 +649,17 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlProjects
Assert.AreEqual(1, service.Projects[projectUri].SqlCmdVariables.Count, "Number of SQLCMD variables after addition not as expected");
Assert.IsTrue(service.Projects[projectUri].SqlCmdVariables.Contains(variableName), $"List of SQLCMD variables expected to contain {variableName}");
// Validate getting a list of the SQLCMD variables
MockRequest<GetSqlCmdVariablesResult> getMock = new();
await service.HandleGetSqlCmdVariablesRequest(new SqlProjectParams()
{
ProjectUri = projectUri
}, getMock.Object);
getMock.AssertSuccess(nameof(service.HandleGetSqlCmdVariablesRequest));
Assert.AreEqual(1, getMock.Result.SqlCmdVariables.Length);
Assert.AreEqual(variableName, getMock.Result.SqlCmdVariables[0].VarName);
// Validate updating a SQLCMD variable
const string updatedDefaultValue = "$(UpdatedDefaultValue)";
const string updatedValue = "$(UpdatedValue)";