mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Merge create db work in progress (#341)
* Port over initial block of create db implementation * Test case placeholder * In-progress work * Stage changes to other machine * Add database prototype strings * Stage changes to other machine * Stage changes * Hook the database info into capabilities discovery * Stage changes * Update SMO to latest from ssms_main * Various clean-ups * Update localization files
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
using Xunit;
|
||||
using Moq;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.Admin.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Admin;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AdminServices
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests for the ServiceHost Language Service tests
|
||||
/// </summary>
|
||||
public class CreateDatabaseTests
|
||||
{
|
||||
private LiveConnectionHelper.TestConnectionResult GetLiveAutoCompleteTestObjects()
|
||||
{
|
||||
var textDocument = new TextDocumentPosition
|
||||
{
|
||||
TextDocument = new TextDocumentIdentifier { Uri = Test.Common.Constants.OwnerUri },
|
||||
Position = new Position
|
||||
{
|
||||
Line = 0,
|
||||
Character = 0
|
||||
}
|
||||
};
|
||||
|
||||
var result = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||
result.TextDocumentPosition = textDocument;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate creating a database with valid input
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void CreateDatabaseWithValidInputTest()
|
||||
{
|
||||
var result = GetLiveAutoCompleteTestObjects();
|
||||
var requestContext = new Mock<RequestContext<CreateDatabaseResponse>>();
|
||||
requestContext.Setup(x => x.SendResult(It.IsAny<CreateDatabaseResponse>())).Returns(Task.FromResult(new object()));
|
||||
|
||||
var dbParams = new CreateDatabaseParams
|
||||
{
|
||||
OwnerUri = result.ConnectionInfo.OwnerUri,
|
||||
DatabaseInfo = new DatabaseInfo()
|
||||
};
|
||||
|
||||
await AdminService.HandleCreateDatabaseRequest(dbParams, requestContext.Object);
|
||||
|
||||
requestContext.VerifyAll();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a default database info object
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void GetDefaultDatebaseInfoTest()
|
||||
{
|
||||
var result = GetLiveAutoCompleteTestObjects();
|
||||
var requestContext = new Mock<RequestContext<DefaultDatabaseInfoResponse>>();
|
||||
requestContext.Setup(x => x.SendResult(It.IsAny<DefaultDatabaseInfoResponse>())).Returns(Task.FromResult(new object()));
|
||||
|
||||
var dbParams = new DefaultDatabaseInfoParams
|
||||
{
|
||||
OwnerUri = result.ConnectionInfo.OwnerUri
|
||||
};
|
||||
|
||||
await AdminService.HandleDefaultDatabaseInfoRequest(dbParams, requestContext.Object);
|
||||
|
||||
requestContext.VerifyAll();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user