include additional data for error object (#1539)

* include additional data for error

* fix tests
This commit is contained in:
Alan Ren
2022-06-10 20:40:22 -07:00
committed by GitHub
parent 5e3d24bbfa
commit 17b6073c87
14 changed files with 64 additions and 54 deletions

View File

@@ -114,11 +114,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking
.Returns(Task.FromResult(0));
// Add general handler for error event
Context.AddErrorHandling((msg, code) =>
Context.AddErrorHandling((msg, code, data) =>
{
ReceivedEvents.Add(new ReceivedEvent
{
EventObject = new Error {Message = msg, Code = code},
EventObject = new Error { Message = msg, Code = code, Data = data },
EventType = EventTypes.Error
});
});
@@ -154,15 +154,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking
// Step 1) Make sure the event type matches
Assert.True(expected.EventType.Equals(received.EventType),
string.Format("Expected EventType {0} but got {1}. Received object is {2}", expected.EventType, received.EventType, received.EventObject.ToString()));
// Step 2) Make sure the param type matches
Assert.True( expected.ParamType == received.EventObject.GetType()
, $"expected and received event types differ for event Number: {i+1}. Expected EventType: {expected.ParamType} & Received EventType: {received.EventObject.GetType()}\r\n"
Assert.True(expected.ParamType == received.EventObject.GetType()
, $"expected and received event types differ for event Number: {i + 1}. Expected EventType: {expected.ParamType} & Received EventType: {received.EventObject.GetType()}\r\n"
+ $"\there is the full list of expected and received events::"
+ $"\r\n\t\t expected event types:{string.Join("\r\n\t\t", ExpectedEvents.ConvertAll(evt=>evt.ParamType))}"
+ $"\r\n\t\t received event types:{string.Join("\r\n\t\t", ReceivedEvents.ConvertAll(evt=>evt.EventObject.GetType()))}"
+ $"\r\n\t\t expected event types:{string.Join("\r\n\t\t", ExpectedEvents.ConvertAll(evt => evt.ParamType))}"
+ $"\r\n\t\t received event types:{string.Join("\r\n\t\t", ReceivedEvents.ConvertAll(evt => evt.EventObject.GetType()))}"
);
// Step 3) Run the validator on the param object
Assert.NotNull(received.EventObject);
expected.Validator?.DynamicInvoke(received.EventObject);