mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-10 18:22:36 -05:00
Add v2 of the Hosting Service and build nuget packages for it (#675)
* Port v2 of Hosting service to SqlToolsService - Renamed project to .v2 so that existing hosted service isn't impacted - Copied over the CoreServices project which contains ConnectionServiceCore and other reusable services for anything interacting with MSSQL - Ported unit test project across and verified tests run. * Nuget package support for reusable DLLs * Use 1.1 version per Karl's suggestion * Use correct license URL and project URL * Use new SMO packages
This commit is contained in:
67
test/Microsoft.SqlTools.Hosting.UnitTests/CommonObjects.cs
Normal file
67
test/Microsoft.SqlTools.Hosting.UnitTests/CommonObjects.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Microsoft.SqlTools.Hosting.Contracts;
|
||||
using Microsoft.SqlTools.Hosting.Contracts.Internal;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.SqlTools.Hosting.UnitTests
|
||||
{
|
||||
public static class CommonObjects
|
||||
{
|
||||
public const string MessageId = "123";
|
||||
|
||||
public static readonly RequestType<TestMessageContents, TestMessageContents> RequestType =
|
||||
RequestType<TestMessageContents, TestMessageContents>.Create("test/request");
|
||||
|
||||
public static readonly EventType<TestMessageContents> EventType =
|
||||
EventType<TestMessageContents>.Create("test/event");
|
||||
|
||||
public static readonly Message RequestMessage =
|
||||
Message.CreateRequest(RequestType, MessageId, TestMessageContents.DefaultInstance);
|
||||
|
||||
public static readonly Message ResponseMessage =
|
||||
Message.CreateResponse(MessageId, TestMessageContents.DefaultInstance);
|
||||
|
||||
public static readonly Message EventMessage =
|
||||
Message.CreateEvent(EventType, TestMessageContents.DefaultInstance);
|
||||
|
||||
public static class TestErrorContents
|
||||
{
|
||||
public static readonly JToken SerializedContents = JToken.Parse("{\"code\": 123, \"message\": \"error\"}");
|
||||
public static readonly Error DefaultInstance = new Error {Code = 123, Message = "error"};
|
||||
}
|
||||
|
||||
public class TestMessageContents : IEquatable<TestMessageContents>
|
||||
{
|
||||
public const string JsonContents = "{\"someField\": \"Some value\", \"number\": 42}";
|
||||
public static readonly JToken SerializedContents = JToken.Parse(JsonContents);
|
||||
public static readonly TestMessageContents DefaultInstance = new TestMessageContents {Number = 42, SomeField = "Some value"};
|
||||
|
||||
public string SomeField { get; set; }
|
||||
public int Number { get; set; }
|
||||
|
||||
public bool Equals(TestMessageContents other)
|
||||
{
|
||||
return string.Equals(SomeField, other.SomeField)
|
||||
&& Number == other.Number;
|
||||
}
|
||||
|
||||
public static bool operator ==(TestMessageContents obj1, TestMessageContents obj2)
|
||||
{
|
||||
bool bothNull = ReferenceEquals(obj1, null) && ReferenceEquals(obj2, null);
|
||||
bool someNull = ReferenceEquals(obj1, null) || ReferenceEquals(obj2, null);
|
||||
return bothNull || !someNull && obj1.Equals(obj2);
|
||||
}
|
||||
|
||||
public static bool operator !=(TestMessageContents obj1, TestMessageContents obj2)
|
||||
{
|
||||
return !(obj1 == obj2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user