Fix failing Loc lookups in hosting service (#679)

* Remove XUnit warnings which clogged up output

* Use default namespace to fix loc lookup errors
- Fixed errors due to localization change
- Also removed internals visible attribute that could cause subtle issues where the hosting service doesn't work for other apps if things change

* Add CI build and test for new projects

* Up version number so we can pick up fix in nuget packages
This commit is contained in:
Kevin Cunnane
2018-08-08 16:21:21 -07:00
committed by GitHub
parent d9e8d5ac12
commit f0b85bab3c
10 changed files with 37 additions and 25 deletions

View File

@@ -23,7 +23,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
eventContext.SendEvent(CommonObjects.EventType, CommonObjects.TestMessageContents.DefaultInstance);
// Then: The message should be added to the queue
Assert.Equal(1, bc.ToArray().Length);
Assert.Single(bc.ToArray());
Assert.Equal(MessageType.Event, bc.ToArray()[0].MessageType);
}
}

View File

@@ -72,7 +72,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
jh.SetAsyncRequestHandler(CommonObjects.RequestType, requestHandler.Object);
// Then: It should be the only request handler set
Assert.Equal(1, jh.requestHandlers.Count);
Assert.Single(jh.requestHandlers);
Assert.Contains(CommonObjects.RequestType.MethodName, jh.requestHandlers.Keys);
// If: I call the stored request handler
@@ -105,7 +105,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
jh.SetRequestHandler(CommonObjects.RequestType, requestHandler.Object);
// Then: It should be the only request handler set
Assert.Equal(1, jh.requestHandlers.Count);
Assert.Single(jh.requestHandlers);
Assert.Contains(CommonObjects.RequestType.MethodName, jh.requestHandlers.Keys);
// If: I call the stored request handler
@@ -137,7 +137,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
jh.SetAsyncRequestHandler(CommonObjects.RequestType, requestHandler2.Object, true);
// Then: There should only be one request handler
Assert.Equal(1, jh.requestHandlers.Count);
Assert.Single(jh.requestHandlers);
Assert.Contains(CommonObjects.RequestType.MethodName, jh.requestHandlers.Keys);
// If: I call the stored request handler
@@ -215,7 +215,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
jh.SetAsyncEventHandler(CommonObjects.EventType, eventHandler.Object);
// Then: It should be the only event handler set
Assert.Equal(1, jh.eventHandlers.Count);
Assert.Single(jh.eventHandlers);
Assert.Contains(CommonObjects.EventType.MethodName, jh.eventHandlers.Keys);
// If: I call the stored event handler
@@ -248,7 +248,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
jh.SetEventHandler(CommonObjects.EventType, eventHandler.Object);
// Then: It should be the only event handler set
Assert.Equal(1, jh.eventHandlers.Count);
Assert.Single(jh.eventHandlers);
Assert.Contains(CommonObjects.EventType.MethodName, jh.eventHandlers.Keys);
// If: I call the stored event handler
@@ -281,7 +281,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
jh.SetAsyncEventHandler(CommonObjects.EventType, eventHandler2.Object, true);
// Then: There should only be one event handler
Assert.Equal(1, jh.eventHandlers.Count);
Assert.Single(jh.eventHandlers);
Assert.Contains(CommonObjects.EventType.MethodName, jh.eventHandlers.Keys);
// If: I call the stored event handler
@@ -336,7 +336,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
jh.SendEvent(CommonObjects.EventType, CommonObjects.TestMessageContents.DefaultInstance);
// Then: The message should be added to the output queue
Assert.Equal(1, jh.outputQueue.ToArray().Length);
Assert.Single(jh.outputQueue.ToArray());
var m = jh.outputQueue.ToArray()[0];
Assert.Equal(CommonObjects.TestMessageContents.SerializedContents, m.Contents);
Assert.Equal(CommonObjects.EventType.MethodName, m.Method);
@@ -363,7 +363,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
Task<CommonObjects.TestMessageContents> requestTask = jh.SendRequest(CommonObjects.RequestType, CommonObjects.TestMessageContents.DefaultInstance);
// Then: There should be a pending request
Assert.Equal(1, jh.pendingRequests.Count);
Assert.Single(jh.pendingRequests);
// If: I then trick it into completing the request
jh.pendingRequests.First().Value.SetResult(CommonObjects.ResponseMessage);
@@ -610,7 +610,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
// ... There should be an outgoing message with the error
var outgoing = jh.outputQueue.ToArray();
Assert.Equal(1, outgoing.Length);
Assert.Single(outgoing);
Assert.Equal(MessageType.ResponseError, outgoing[0].MessageType);
Assert.Equal(CommonObjects.MessageId, outgoing[0].Id);
Assert.Equal(-32601, outgoing[0].Contents.Value<int>("code"));
@@ -643,7 +643,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
// ... There should not be any outgoing messages
var outgoing = jh.outputQueue.ToArray();
Assert.Equal(0, outgoing.Length);
Assert.Empty(outgoing);
}
#endregion

View File

@@ -5,6 +5,7 @@
using System;
using System.Collections.Concurrent;
using System.Linq;
using Microsoft.SqlTools.Hosting.Contracts.Internal;
using Microsoft.SqlTools.Hosting.Protocol;
using Xunit;
@@ -26,8 +27,8 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
rc.SendResult(CommonObjects.TestMessageContents.DefaultInstance);
// Then: The message writer should have sent a response
Assert.Equal(1, bc.ToArray().Length);
Assert.Equal(MessageType.Response, bc.ToArray()[0].MessageType);
Assert.Single(bc);
Assert.Equal(MessageType.Response, bc.First().MessageType);
}
[Fact]
@@ -41,8 +42,8 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
rc.SendEvent(CommonObjects.EventType, CommonObjects.TestMessageContents.DefaultInstance);
// Then: The message writer should have sent an event
Assert.Equal(1, bc.ToArray().Length);
Assert.Equal(MessageType.Event, bc.ToArray()[0].MessageType);
Assert.Single(bc);
Assert.Equal(MessageType.Event, bc.First().MessageType);
}
[Fact]
@@ -59,8 +60,8 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
// Then:
// ... The message writer should have sent an error
Assert.Equal(1, bc.ToArray().Length);
Assert.Equal(MessageType.ResponseError, bc.ToArray()[0].MessageType);
Assert.Single(bc);
Assert.Equal(MessageType.ResponseError, bc.First().MessageType);
// ... The error object it built should have the reuired fields set
var contents = bc.ToArray()[0].GetTypedContents<Error>();
@@ -82,11 +83,12 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
// Then:
// ... The message writer should have sent an error
Assert.Equal(1, bc.ToArray().Length);
Assert.Equal(MessageType.ResponseError, bc.ToArray()[0].MessageType);
Assert.Single(bc);
var firstMessage = bc.First();
Assert.Equal(MessageType.ResponseError, firstMessage.MessageType);
// ... The error object it built should have the reuired fields set
var contents = bc.ToArray()[0].GetTypedContents<Error>();
var contents = firstMessage.GetTypedContents<Error>();
Assert.Equal(e.HResult, contents.Code);
Assert.Equal(errorMessage, contents.Message);