Update MsgPack-Cli version

* Fixes #1301
* Fixes #1058
* Fixes #1422
This commit is contained in:
Andrew Stanton-Nurse 2018-02-16 10:43:32 -08:00
parent c8d4cf689f
commit b3a33efeae
12 changed files with 362 additions and 379 deletions

View File

@ -56,7 +56,7 @@
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview2-26130-04</MicrosoftNETCoreApp21PackageVersion> <MicrosoftNETCoreApp21PackageVersion>2.1.0-preview2-26130-04</MicrosoftNETCoreApp21PackageVersion>
<MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion> <MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion>
<MoqPackageVersion>4.7.49</MoqPackageVersion> <MoqPackageVersion>4.7.49</MoqPackageVersion>
<MsgPackCliPackageVersion>0.9.0-beta2</MsgPackCliPackageVersion> <MsgPackCliPackageVersion>1.0.0-rc</MsgPackCliPackageVersion>
<NewtonsoftJsonPackageVersion>10.0.1</NewtonsoftJsonPackageVersion> <NewtonsoftJsonPackageVersion>10.0.1</NewtonsoftJsonPackageVersion>
<StackExchangeRedisStrongNamePackageVersion>1.2.4</StackExchangeRedisStrongNamePackageVersion> <StackExchangeRedisStrongNamePackageVersion>1.2.4</StackExchangeRedisStrongNamePackageVersion>
<SystemBuffersPackageVersion>4.5.0-preview2-26130-01</SystemBuffersPackageVersion> <SystemBuffersPackageVersion>4.5.0-preview2-26130-01</SystemBuffersPackageVersion>

View File

@ -18,7 +18,7 @@
"build:cjs": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs --target ES5", "build:cjs": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs --target ES5",
"build:browser": "node ../node_modules/rollup/bin/rollup -c", "build:browser": "node ../node_modules/rollup/bin/rollup -c",
"build:uglify": "node ../node_modules/uglify-js/bin/uglifyjs --source-map \"url='signalr-protocol-msgpack.min.js.map',content='./dist/browser/signalr-protocol-msgpack.js.map'\" --comments -o ./dist/browser/signalr-protocol-msgpack.min.js ./dist/browser/signalr-protocol-msgpack.js", "build:uglify": "node ../node_modules/uglify-js/bin/uglifyjs --source-map \"url='signalr-protocol-msgpack.min.js.map',content='./dist/browser/signalr-protocol-msgpack.js.map'\" --comments -o ./dist/browser/signalr-protocol-msgpack.min.js ./dist/browser/signalr-protocol-msgpack.js",
"pretest": "node ../node_modules/rimraf/bin.js ./spec/obj && tsc --project ./spec/tsconfig.json", "pretest": "node ../node_modules/rimraf/bin.js ./spec/obj && node ../node_modules/typescript/bin/tsc --project ./spec/tsconfig.json",
"test": "node ../node_modules/jasmine/bin/jasmine.js ./spec/obj/signalr-protocol-msgpack/spec/**/*.spec.js" "test": "node ../node_modules/jasmine/bin/jasmine.js ./spec/obj/signalr-protocol-msgpack/spec/**/*.spec.js"
}, },
"keywords": [ "keywords": [

View File

@ -1,111 +1,139 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
import { MessagePackHubProtocol } from "../src/MessagePackHubProtocol" import { CompletionMessage, InvocationMessage, MessageType, StreamItemMessage } from "@aspnet/signalr";
import { MessageType, InvocationMessage, CompletionMessage, StreamItemMessage } from "@aspnet/signalr" import { MessagePackHubProtocol } from "../src/MessagePackHubProtocol";
describe("MessageHubProtocol", () => { describe("MessageHubProtocol", () => {
it("can write/read non-blocking Invocation message", () => { it("can write/read non-blocking Invocation message", () => {
let invocation = <InvocationMessage>{ const invocation = {
arguments: [42, true, "test", ["x1", "y2"], null],
headers: {}, headers: {},
type: MessageType.Invocation,
target: "myMethod", target: "myMethod",
arguments: [42, true, "test", ["x1", "y2"], null] type: MessageType.Invocation,
}; } as InvocationMessage;
let protocol = new MessagePackHubProtocol(); const protocol = new MessagePackHubProtocol();
var parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation)); const parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation));
expect(parsedMessages).toEqual([invocation]);
});
it("can read Invocation message with Date argument", () => {
const invocation = {
arguments: [new Date(Date.UTC(2018, 1, 1, 12, 34, 56))],
headers: {},
target: "mymethod",
type: MessageType.Invocation,
} as InvocationMessage;
const protocol = new MessagePackHubProtocol();
const parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation));
expect(parsedMessages).toEqual([invocation]); expect(parsedMessages).toEqual([invocation]);
}); });
it("can write/read Invocation message with headers", () => { it("can write/read Invocation message with headers", () => {
let invocation = <InvocationMessage>{ const invocation = {
arguments: [42, true, "test", ["x1", "y2"], null],
headers: { headers: {
"foo": "bar" foo: "bar",
}, },
type: MessageType.Invocation,
target: "myMethod", target: "myMethod",
arguments: [42, true, "test", ["x1", "y2"], null] type: MessageType.Invocation,
}; } as InvocationMessage;
let protocol = new MessagePackHubProtocol(); const protocol = new MessagePackHubProtocol();
var parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation)); const parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation));
expect(parsedMessages).toEqual([invocation]); expect(parsedMessages).toEqual([invocation]);
}); });
it("can write/read Invocation message", () => { it("can write/read Invocation message", () => {
let invocation = <InvocationMessage>{ const invocation = {
arguments: [42, true, "test", ["x1", "y2"], null],
headers: {}, headers: {},
type: MessageType.Invocation,
invocationId: "123", invocationId: "123",
target: "myMethod", target: "myMethod",
arguments: [42, true, "test", ["x1", "y2"], null] type: MessageType.Invocation,
}; } as InvocationMessage;
let protocol = new MessagePackHubProtocol(); const protocol = new MessagePackHubProtocol();
var parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation)); const parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation));
expect(parsedMessages).toEqual([invocation]); expect(parsedMessages).toEqual([invocation]);
}); });
([ ([
[[0x0c, 0x95, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x01, 0xa3, 0x45, 0x72, 0x72], [[0x0c, 0x95, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x01, 0xa3, 0x45, 0x72, 0x72],
{ {
headers: {},
type: MessageType.Completion,
invocationId: "abc",
error: "Err", error: "Err",
result: null headers: {},
invocationId: "abc",
result: null,
type: MessageType.Completion,
} as CompletionMessage], } as CompletionMessage],
[[0x0b, 0x95, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x03, 0xa2, 0x4f, 0x4b], [[0x0b, 0x95, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x03, 0xa2, 0x4f, 0x4b],
{ {
headers: {},
type: MessageType.Completion,
invocationId: "abc",
error: null, error: null,
result: "OK" headers: {},
invocationId: "abc",
result: "OK",
type: MessageType.Completion,
} as CompletionMessage], } as CompletionMessage],
[[0x08, 0x94, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x02], [[0x08, 0x94, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x02],
{ {
headers: {},
type: MessageType.Completion,
invocationId: "abc",
error: null, error: null,
result: null headers: {},
} as CompletionMessage] invocationId: "abc",
] as [number[], CompletionMessage][]).forEach(([payload, expected_message]) => result: null,
type: MessageType.Completion,
} as CompletionMessage],
[[0x0E, 0x95, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x03, 0xD6, 0xFF, 0x5A, 0x4A, 0x1A, 0x50],
{
error: null,
headers: {},
invocationId: "abc",
result: new Date(Date.UTC(2018, 0, 1, 11, 24, 0)),
type: MessageType.Completion,
} as CompletionMessage],
] as Array<[number[], CompletionMessage]>).forEach(([payload, expectedMessage]) =>
it("can read Completion message", () => { it("can read Completion message", () => {
let messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer); const messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
expect(messages).toEqual([expected_message]); expect(messages).toEqual([expectedMessage]);
})); }));
([ ([
[[0x08, 0x94, 0x02, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x08], [[0x08, 0x94, 0x02, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x08],
{ {
headers: {}, headers: {},
type: MessageType.StreamItem,
invocationId: "abc", invocationId: "abc",
item: 8 item: 8,
type: MessageType.StreamItem,
} as StreamItemMessage],
[[0x0D, 0x94, 0x02, 0x80, 0xa3, 0x61, 0x62, 0x63, 0xD6, 0xFF, 0x5A, 0x4A, 0x1A, 0x50],
{
headers: {},
invocationId: "abc",
item: new Date(Date.UTC(2018, 0, 1, 11, 24, 0)),
type: MessageType.StreamItem,
} as StreamItemMessage] } as StreamItemMessage]
] as [[number[], StreamItemMessage]]).forEach(([payload, expected_message]) => ] as Array<[number[], StreamItemMessage]>).forEach(([payload, expectedMessage]) =>
it("can read StreamItem message", () => { it("can read StreamItem message", () => {
let messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer); const messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
expect(messages).toEqual([expected_message]); expect(messages).toEqual([expectedMessage]);
})); }));
([ ([
[[0x0c, 0x94, 0x02, 0x81, 0xa1, 0x74, 0xa1, 0x75, 0xa3, 0x61, 0x62, 0x63, 0x08], [[0x0c, 0x94, 0x02, 0x81, 0xa1, 0x74, 0xa1, 0x75, 0xa3, 0x61, 0x62, 0x63, 0x08],
{ {
headers: { headers: {
"t": "u" t: "u",
}, },
type: MessageType.StreamItem,
invocationId: "abc", invocationId: "abc",
item: 8 item: 8,
} as StreamItemMessage] type: MessageType.StreamItem,
] as [[number[], StreamItemMessage]]).forEach(([payload, expected_message]) => } as StreamItemMessage],
] as Array<[number[], StreamItemMessage]>).forEach(([payload, expectedMessage]) =>
it("can read message with headers", () => { it("can read message with headers", () => {
let messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer); const messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
expect(messages).toEqual([expected_message]); expect(messages).toEqual([expectedMessage]);
})); }));
([ ([
@ -120,46 +148,46 @@ describe("MessageHubProtocol", () => {
["Completion message with invalid invocation id", [0x04, 0x93, 0x03, 0x80, 0xa0], new Error("Invalid payload for Completion message.")], ["Completion message with invalid invocation id", [0x04, 0x93, 0x03, 0x80, 0xa0], new Error("Invalid payload for Completion message.")],
["Completion message with unexpected result", [0x06, 0x95, 0x03, 0x80, 0xa0, 0x02, 0x00], new Error("Invalid payload for Completion message.")], ["Completion message with unexpected result", [0x06, 0x95, 0x03, 0x80, 0xa0, 0x02, 0x00], new Error("Invalid payload for Completion message.")],
["Completion message with missing result", [0x05, 0x94, 0x03, 0x80, 0xa0, 0x01], new Error("Invalid payload for Completion message.")], ["Completion message with missing result", [0x05, 0x94, 0x03, 0x80, 0xa0, 0x01], new Error("Invalid payload for Completion message.")],
["Completion message with missing error", [0x05, 0x94, 0x03, 0x80, 0xa0, 0x03], new Error("Invalid payload for Completion message.")] ["Completion message with missing error", [0x05, 0x94, 0x03, 0x80, 0xa0, 0x03], new Error("Invalid payload for Completion message.")],
] as [string, number[], Error][]).forEach(([name, payload, expected_error]) => ] as Array<[string, number[], Error]>).forEach(([name, payload, expectedError]) =>
it("throws for " + name, () => { it("throws for " + name, () => {
expect(() => new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer)) expect(() => new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer))
.toThrow(expected_error); .toThrow(expectedError);
})); }));
it("can read multiple messages", () => { it("can read multiple messages", () => {
let payload = [ const payload = [
0x08, 0x94, 0x02, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x08, 0x08, 0x94, 0x02, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x08,
0x0b, 0x95, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x03, 0xa2, 0x4f, 0x4b]; 0x0b, 0x95, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x03, 0xa2, 0x4f, 0x4b];
let messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer); const messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
expect(messages).toEqual([ expect(messages).toEqual([
{ {
headers: {}, headers: {},
type: MessageType.StreamItem,
invocationId: "abc", invocationId: "abc",
item: 8 item: 8,
type: MessageType.StreamItem,
} as StreamItemMessage, } as StreamItemMessage,
{ {
headers: {},
type: MessageType.Completion,
invocationId: "abc",
error: null, error: null,
result: "OK" headers: {},
} as CompletionMessage invocationId: "abc",
result: "OK",
type: MessageType.Completion,
} as CompletionMessage,
]); ]);
}); });
it("can read ping message", () => { it("can read ping message", () => {
let payload = [ const payload = [
0x02, 0x02,
0x91, // message array length = 1 (fixarray) 0x91, // message array length = 1 (fixarray)
0x06, // type = 6 = Ping (fixnum) 0x06, // type = 6 = Ping (fixnum)
]; ];
let messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer); const messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
expect(messages).toEqual([ expect(messages).toEqual([
{ {
type: MessageType.Ping, type: MessageType.Ping,
} },
]) ]);
}) });
}); });

View File

@ -18,7 +18,7 @@
"build:cjs": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs --target ES5", "build:cjs": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs --target ES5",
"build:browser": "node ../node_modules/rollup/bin/rollup -c", "build:browser": "node ../node_modules/rollup/bin/rollup -c",
"build:uglify": "node ../node_modules/uglify-js/bin/uglifyjs --source-map \"url='signalr.min.js.map',content='./dist/browser/signalr.js.map'\" --comments -o ./dist/browser/signalr.min.js ./dist/browser/signalr.js", "build:uglify": "node ../node_modules/uglify-js/bin/uglifyjs --source-map \"url='signalr.min.js.map',content='./dist/browser/signalr.js.map'\" --comments -o ./dist/browser/signalr.min.js ./dist/browser/signalr.js",
"pretest": "node ../node_modules/rimraf/bin.js ./spec/obj && tsc --project ./spec/tsconfig.json", "pretest": "node ../node_modules/rimraf/bin.js ./spec/obj && node ../node_modules/typescript/bin/tsc --project ./spec/tsconfig.json",
"test": "node ../node_modules/jasmine/bin/jasmine.js ./spec/obj/spec/**/*.spec.js" "test": "node ../node_modules/jasmine/bin/jasmine.js ./spec/obj/spec/**/*.spec.js"
}, },
"repository": { "repository": {

View File

@ -3,6 +3,7 @@
"compilerOptions": { "compilerOptions": {
"module": "es2015", "module": "es2015",
"target": "es2016", "target": "es2016",
"outDir": "./obj/js",
"sourceMap": true, "sourceMap": true,
"moduleResolution": "node", "moduleResolution": "node",
"inlineSources": true, "inlineSources": true,

View File

@ -7,6 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.MsgPack\Microsoft.AspNetCore.SignalR.MsgPack.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj" /> <ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Sockets.Http\Microsoft.AspNetCore.Sockets.Http.csproj" /> <ProjectReference Include="..\..\src\Microsoft.AspNetCore.Sockets.Http\Microsoft.AspNetCore.Sockets.Http.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Redis\Microsoft.AspNetCore.SignalR.Redis.csproj" /> <ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Redis\Microsoft.AspNetCore.SignalR.Redis.csproj" />
@ -29,7 +30,12 @@
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr\dist\browser\*" /> <SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr\dist\browser\*" />
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr-protocol-msgpack\dist\browser\*" /> <SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr-protocol-msgpack\dist\browser\*" />
</ItemGroup> </ItemGroup>
<Copy SourceFiles="@(SignalRJSClientFiles)" DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr-client" /> <Copy SourceFiles="@(SignalRJSClientFiles)" DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr" />
<ItemGroup>
<MsgPackClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr-protocol-msgpack\node_modules\msgpack5\dist\*" />
</ItemGroup>
<Copy SourceFiles="@(MsgPackClientFiles)" DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\msgpack5" />
</Target> </Target>
</Project> </Project>

View File

@ -5,9 +5,10 @@ using System;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Serialization; using MsgPack.Serialization;
using SocketsSample.EndPoints; using SocketsSample.EndPoints;
using SocketsSample.Hubs; using SocketsSample.Hubs;
using StackExchange.Redis;
namespace SocketsSample namespace SocketsSample
{ {
@ -23,6 +24,10 @@ namespace SocketsSample
{ {
// Faster pings for testing // Faster pings for testing
options.KeepAliveInterval = TimeSpan.FromSeconds(5); options.KeepAliveInterval = TimeSpan.FromSeconds(5);
})
.AddMessagePackProtocol(options =>
{
options.SerializationContext.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel;
}); });
// .AddRedis(); // .AddRedis();

View File

@ -1,4 +1,4 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -7,11 +7,23 @@
</head> </head>
<body> <body>
<h1 id="head1"></h1> <h1 id="head1">SignalR Hubs Sample</h1>
<div> <div>
<select id="formatType"> <select id="protocol">
<option value="json">json</option> <option value="json" selected>json</option>
<option value="line">line</option> <option value="msgpack">msgpack</option>
</select>
<select id="transport">
<option value="WebSockets" selected>WebSockets</option>
<option value="ServerSentEvents">ServerSentEvents</option>
<option value="LongPolling">LongPolling</option>
</select>
<select id="hubType">
<option value="default" selected>Hub</option>
<option value="dynamic">DynamicHub</option>
<option value="hubT">Hub&lt;T&gt;</option>
</select> </select>
<input type="button" id="connect" value="Connect" /> <input type="button" id="connect" value="Connect" />
@ -62,7 +74,9 @@
</body> </body>
</html> </html>
<script src="lib/signalr-client/signalr.js"></script> <script src="lib/signalr/signalr.js"></script>
<script src="lib/msgpack5/msgpack5.js"></script>
<script src="lib/signalr/signalr-protocol-msgpack.js"></script>
<script src="utils.js"></script> <script src="utils.js"></script>
<script> <script>
var isConnected = false; var isConnected = false;
@ -88,12 +102,7 @@
return document.getElementById(id).value; return document.getElementById(id).value;
} }
let transportType = signalR.TransportType[getParameterByName('transport')] || signalR.TransportType.WebSockets;
let logger = new signalR.ConsoleLogger(signalR.LogLevel.Trace); let logger = new signalR.ConsoleLogger(signalR.LogLevel.Trace);
let hubRoute = getParameterByName('hubType') || "default";
console.log('Hub Route:' + hubRoute);
document.getElementById('head1').innerHTML = signalR.TransportType[transportType];
let connectButton = document.getElementById('connect'); let connectButton = document.getElementById('connect');
let disconnectButton = document.getElementById('disconnect'); let disconnectButton = document.getElementById('disconnect');
@ -105,6 +114,9 @@
let groupMsgButton = document.getElementById('groupmsg'); let groupMsgButton = document.getElementById('groupmsg');
let othersGroupMsgButton = document.getElementById('others-groupmsg'); let othersGroupMsgButton = document.getElementById('others-groupmsg');
let sendButton = document.getElementById('send'); let sendButton = document.getElementById('send');
let protocolDropdown = document.getElementById('protocol');
let transportDropdown = document.getElementById('transport');
let hubTypeDropdown = document.getElementById('hubType');
function updateButtonState(isConnected) { function updateButtonState(isConnected) {
broadcastButton.disabled = !isConnected; broadcastButton.disabled = !isConnected;
@ -123,8 +135,14 @@
var connection; var connection;
click('connect', function (event) { click('connect', function (event) {
let transportType = signalR.TransportType[transportDropdown.value] || signalR.TransportType.WebSockets;
let hubRoute = hubTypeDropdown.value || "default";
let protocol = protocolDropdown.value === "msgpack" ?
new signalR.protocols.msgpack.MessagePackHubProtocol() :
new signalR.JsonHubProtocol();
console.log('http://' + document.location.host + '/' + hubRoute); console.log('http://' + document.location.host + '/' + hubRoute);
connection = new signalR.HubConnection(hubRoute, { transport: transportType, logger: logger }); connection = new signalR.HubConnection(hubRoute, { transport: transportType, logger: logger, protocol: protocol });
connection.on('Send', function (msg) { connection.on('Send', function (msg) {
addLine('message-list', msg); addLine('message-list', msg);
}); });

View File

@ -1,4 +1,4 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
@ -14,21 +14,7 @@
</ul> </ul>
<h1>ASP.NET Core SignalR (Hubs)</h1> <h1>ASP.NET Core SignalR (Hubs)</h1>
<ul> <ul>
<li><a href="hubs.html?transport=LongPolling">Long polling</a></li> <li><a href="hubs.html">Hubs</a></li>
<li><a href="hubs.html?transport=ServerSentEvents">Server Sent Events</a></li>
<li><a href="hubs.html?transport=WebSockets">Web Sockets</a></li>
</ul>
<h1>ASP.NET Core SignalR (Dynamic Hubs)</h1>
<ul>
<li><a href="hubs.html?transport=LongPolling&hubType=dynamic">Long polling</a></li>
<li><a href="hubs.html?transport=ServerSentEvents&hubType=dynamic">Server Sent Events</a></li>
<li><a href="hubs.html?transport=WebSockets&hubType=dynamic">Web Sockets</a></li>
</ul>
<h1>ASP.NET Core SignalR (Hub&lt;T&gt;)</h1>
<ul>
<li><a href="hubs.html?transport=LongPolling&hubType=hubT">Long polling</a></li>
<li><a href="hubs.html?transport=ServerSentEvents&hubType=hubT">Server Sent Events</a></li>
<li><a href="hubs.html?transport=WebSockets&hubType=hubT">Web Sockets</a></li>
</ul> </ul>
<h1>ASP.NET Core SignalR (Streaming)</h1> <h1>ASP.NET Core SignalR (Streaming)</h1>
<ul> <ul>

View File

@ -1,4 +1,4 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -15,7 +15,7 @@
</form> </form>
<ul id="messages"></ul> <ul id="messages"></ul>
<script src="lib/signalr-client/signalr.js"></script> <script src="lib/signalr/signalr.js"></script>
<script src="utils.js"></script> <script src="utils.js"></script>
<script> <script>
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {

View File

@ -1,4 +1,4 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -25,7 +25,7 @@
<ul id="resultsList"></ul> <ul id="resultsList"></ul>
<ul id="messages"></ul> <ul id="messages"></ul>
<script src="lib/signalr-client/signalr.js"></script> <script src="lib/signalr/signalr.js"></script>
<script src="utils.js"></script> <script src="utils.js"></script>
<script> <script>
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {

View File

@ -10,12 +10,11 @@ using Microsoft.AspNetCore.SignalR.Internal.Formatters;
using Microsoft.AspNetCore.SignalR.Internal.Protocol; using Microsoft.AspNetCore.SignalR.Internal.Protocol;
using MsgPack; using MsgPack;
using Xunit; using Xunit;
using Xunit.Abstractions;
namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
{ {
using static MessagePackHelpers;
using static HubMessageHelpers; using static HubMessageHelpers;
using static MessagePackHelpers;
public class MessagePackHubProtocolTests public class MessagePackHubProtocolTests
{ {
@ -36,7 +35,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
private static MessagePackObject CustomObjectSerialized = Map( private static MessagePackObject CustomObjectSerialized = Map(
("ByteArrProp", new MessagePackObject(new byte[] { 1, 2, 3 }, isBinary: true)), ("ByteArrProp", new MessagePackObject(new byte[] { 1, 2, 3 }, isBinary: true)),
("DateTimeProp", new DateTime(2017, 4, 11).Ticks), ("DateTimeProp", new MessagePackObject(Timestamp.FromDateTime(new DateTime(2017, 4, 11)))),
("DoubleProp", 6.2831853071), ("DoubleProp", 6.2831853071),
("IntProp", 42), ("IntProp", 42),
("NullProp", MessagePackObject.Nil), ("NullProp", MessagePackObject.Nil),
@ -56,291 +55,229 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
// If you change MsgPack encoding, you should update the 'encoded' values for these items, and then re-run the test. You'll get a failure which will // If you change MsgPack encoding, you should update the 'encoded' values for these items, and then re-run the test. You'll get a failure which will
// provide a new Base64 binary string to replace in the 'binary' value. Use a tool like https://sugendran.github.io/msgpack-visualizer/ to verify // provide a new Base64 binary string to replace in the 'binary' value. Use a tool like https://sugendran.github.io/msgpack-visualizer/ to verify
// that the MsgPack is correct and then just replace the Base64 value. // that the MsgPack is correct and then just replace the Base64 value.
public static IEnumerable<object[]> TestData => new[]
public static IEnumerable<object[]> TestDataNames
{
get
{
foreach (var k in TestData.Keys)
{
yield return new object[] { k };
}
}
}
public static IDictionary<string, ProtocolTestData> TestData => new[]
{ {
// Invocation messages // Invocation messages
new object[] { new ProtocolTestData(
new ProtocolTestData( name: "InvocationWithNoHeadersAndNoArgs",
name: "InvocationWithNoHeadersAndNoArgs", message: new InvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null),
message: new InvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null), encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), "xyz", "method", Array()),
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), "xyz", "method", Array()), binary: "lQGAo3h5eqZtZXRob2SQ"),
binary: "lQGAo3h5eqZtZXRob2SQ"), new ProtocolTestData(
}, name: "InvocationWithNoHeadersNoIdAndNoArgs",
new object[] { message: new InvocationMessage(target: "method", argumentBindingException: null),
new ProtocolTestData( encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array()),
name: "InvocationWithNoHeadersNoIdAndNoArgs", binary: "lQGAwKZtZXRob2SQ"),
message: new InvocationMessage(target: "method", argumentBindingException: null), new ProtocolTestData(
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array()), name: "InvocationWithNoHeadersNoIdAndSingleNullArg",
binary: "lQGAwKZtZXRob2SQ"), message: new InvocationMessage(target: "method", argumentBindingException: null, new object[] { null }),
}, encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(MessagePackObject.Nil)),
new object[] { binary: "lQGAwKZtZXRob2SRwA=="),
new ProtocolTestData( new ProtocolTestData(
name: "InvocationWithNoHeadersNoIdAndSingleNullArg", name: "InvocationWithNoHeadersNoIdAndSingleIntArg",
message: new InvocationMessage(target: "method", argumentBindingException: null, new object[] { null }), message: new InvocationMessage(target: "method", argumentBindingException: null, 42),
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(MessagePackObject.Nil)), encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42)),
binary: "lQGAwKZtZXRob2SRwA=="), binary: "lQGAwKZtZXRob2SRKg=="),
}, new ProtocolTestData(
new object[] { name: "InvocationWithNoHeadersNoIdIntAndStringArgs",
new ProtocolTestData( message: new InvocationMessage(target: "method", argumentBindingException: null, 42, "string"),
name: "InvocationWithNoHeadersNoIdAndSingleIntArg", encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42, "string")),
message: new InvocationMessage(target: "method", argumentBindingException: null, 42), binary: "lQGAwKZtZXRob2SSKqZzdHJpbmc="),
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42)), new ProtocolTestData(
binary: "lQGAwKZtZXRob2SRKg=="), name: "InvocationWithNoHeadersNoIdAndCustomObjectArg",
}, message: new InvocationMessage(target: "method", argumentBindingException: null, 42, "string", new CustomObject()),
new object[] { encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42, "string", CustomObjectSerialized)),
new ProtocolTestData( binary: "lQGAwKZtZXRob2STKqZzdHJpbmeGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
name: "InvocationWithNoHeadersNoIdIntAndStringArgs", new ProtocolTestData(
message: new InvocationMessage(target: "method", argumentBindingException: null, 42, "string"), name: "InvocationWithNoHeadersNoIdAndArrayOfCustomObjectArgs",
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42, "string")), message: new InvocationMessage(target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() }),
binary: "lQGAwKZtZXRob2SSKqZzdHJpbmc="), encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(CustomObjectSerialized, CustomObjectSerialized)),
}, binary: "lQGAwKZtZXRob2SShqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIhhqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIh"),
new object[] { new ProtocolTestData(
new ProtocolTestData( name: "InvocationWithHeadersNoIdAndArrayOfCustomObjectArgs",
name: "InvocationWithNoHeadersNoIdAndCustomObjectArg", message: AddHeaders(TestHeaders, new InvocationMessage(target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() })),
message: new InvocationMessage(target: "method", argumentBindingException: null, 42, "string", new CustomObject()), encoded: Array(HubProtocolConstants.InvocationMessageType, TestHeadersSerialized, MessagePackObject.Nil, "method", Array(CustomObjectSerialized, CustomObjectSerialized)),
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42, "string", CustomObjectSerialized)), binary: "lQGDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmXApm1ldGhvZJKGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
binary: "lQGAwKZtZXRob2STKqZzdHJpbmeGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
},
new object[] {
new ProtocolTestData(
name: "InvocationWithNoHeadersNoIdAndArrayOfCustomObjectArgs",
message: new InvocationMessage(target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() }),
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(CustomObjectSerialized, CustomObjectSerialized)),
binary: "lQGAwKZtZXRob2SShqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNMI1IBtsnbAAKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIhhqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNMI1IBtsnbAAKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIh"),
},
new object[] {
new ProtocolTestData(
name: "InvocationWithHeadersNoIdAndArrayOfCustomObjectArgs",
message: AddHeaders(TestHeaders, new InvocationMessage(target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() })),
encoded: Array(HubProtocolConstants.InvocationMessageType, TestHeadersSerialized, MessagePackObject.Nil, "method", Array(CustomObjectSerialized, CustomObjectSerialized)),
binary: "lQGDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmXApm1ldGhvZJKGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
},
// StreamItem Messages // StreamItem Messages
new object[] { new ProtocolTestData(
new ProtocolTestData( name: "StreamItemWithNoHeadersAndNullItem",
name: "StreamItemWithNoHeadersAndNullItem", message: new StreamItemMessage(invocationId: "xyz", item: null),
message: new StreamItemMessage(invocationId: "xyz", item: null), encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", MessagePackObject.Nil),
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", MessagePackObject.Nil), binary: "lAKAo3h5esA="),
binary: "lAKAo3h5esA="), new ProtocolTestData(
}, name: "StreamItemWithNoHeadersAndIntItem",
new object[] { message: new StreamItemMessage(invocationId: "xyz", item: 42),
new ProtocolTestData( encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", 42),
name: "StreamItemWithNoHeadersAndIntItem", binary: "lAKAo3h5eio="),
message: new StreamItemMessage(invocationId: "xyz", item: 42), new ProtocolTestData(
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", 42), name: "StreamItemWithNoHeadersAndFloatItem",
binary: "lAKAo3h5eio="), message: new StreamItemMessage(invocationId: "xyz", item: 42.0f),
}, encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", 42.0f),
new object[] { binary: "lAKAo3h5espCKAAA"),
new ProtocolTestData( new ProtocolTestData(
name: "StreamItemWithNoHeadersAndFloatItem", name: "StreamItemWithNoHeadersAndStringItem",
message: new StreamItemMessage(invocationId: "xyz", item: 42.0f), message: new StreamItemMessage(invocationId: "xyz", item: "string"),
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", 42.0f), encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", "string"),
binary: "lAKAo3h5espCKAAA"), binary: "lAKAo3h5eqZzdHJpbmc="),
}, new ProtocolTestData(
new object[] { name: "StreamItemWithNoHeadersAndBoolItem",
new ProtocolTestData( message: new StreamItemMessage(invocationId: "xyz", item: true),
name: "StreamItemWithNoHeadersAndStringItem", encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", true),
message: new StreamItemMessage(invocationId: "xyz", item: "string"), binary: "lAKAo3h5esM="),
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", "string"), new ProtocolTestData(
binary: "lAKAo3h5eqZzdHJpbmc="), name: "StreamItemWithNoHeadersAndCustomObjectItem",
}, message: new StreamItemMessage(invocationId: "xyz", item: new CustomObject()),
new object[] { encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", CustomObjectSerialized),
new ProtocolTestData( binary: "lAKAo3h5eoarQnl0ZUFyclByb3DEAwECA6xEYXRlVGltZVByb3DW/1jsHICqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqhOdWxsUHJvcMCqU3RyaW5nUHJvcKhTaWduYWxSIQ=="),
name: "StreamItemWithNoHeadersAndBoolItem", new ProtocolTestData(
message: new StreamItemMessage(invocationId: "xyz", item: true), name: "StreamItemWithNoHeadersAndCustomObjectArrayItem",
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", true), message: new StreamItemMessage(invocationId: "xyz", item: new[] { new CustomObject(), new CustomObject() }),
binary: "lAKAo3h5esM="), encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", Array(CustomObjectSerialized, CustomObjectSerialized)),
}, binary: "lAKAo3h5epKGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
new object[] { new ProtocolTestData(
new ProtocolTestData( name: "StreamItemWithHeadersAndCustomObjectArrayItem",
name: "StreamItemWithNoHeadersAndCustomObjectItem", message: AddHeaders(TestHeaders, new StreamItemMessage(invocationId: "xyz", item: new[] { new CustomObject(), new CustomObject() })),
message: new StreamItemMessage(invocationId: "xyz", item: new CustomObject()), encoded: Array(HubProtocolConstants.StreamItemMessageType, TestHeadersSerialized, "xyz", Array(CustomObjectSerialized, CustomObjectSerialized)),
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", CustomObjectSerialized), binary: "lAKDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6koarQnl0ZUFyclByb3DEAwECA6xEYXRlVGltZVByb3DW/1jsHICqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqhOdWxsUHJvcMCqU3RyaW5nUHJvcKhTaWduYWxSIYarQnl0ZUFyclByb3DEAwECA6xEYXRlVGltZVByb3DW/1jsHICqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqhOdWxsUHJvcMCqU3RyaW5nUHJvcKhTaWduYWxSIQ=="),
binary: "lAKAo3h5eoarQnl0ZUFyclByb3DEAwECA6xEYXRlVGltZVByb3DTCNSAbbJ2wACqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqhOdWxsUHJvcMCqU3RyaW5nUHJvcKhTaWduYWxSIQ=="),
},
new object[] {
new ProtocolTestData(
name: "StreamItemWithNoHeadersAndCustomObjectArrayItem",
message: new StreamItemMessage(invocationId: "xyz", item: new[] { new CustomObject(), new CustomObject() }),
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", Array(CustomObjectSerialized, CustomObjectSerialized)),
binary: "lAKAo3h5epKGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
},
new object[] {
new ProtocolTestData(
name: "StreamItemWithHeadersAndCustomObjectArrayItem",
message: AddHeaders(TestHeaders, new StreamItemMessage(invocationId: "xyz", item: new[] { new CustomObject(), new CustomObject() })),
encoded: Array(HubProtocolConstants.StreamItemMessageType, TestHeadersSerialized, "xyz", Array(CustomObjectSerialized, CustomObjectSerialized)),
binary: "lAKDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6koarQnl0ZUFyclByb3DEAwECA6xEYXRlVGltZVByb3DTCNSAbbJ2wACqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqhOdWxsUHJvcMCqU3RyaW5nUHJvcKhTaWduYWxSIYarQnl0ZUFyclByb3DEAwECA6xEYXRlVGltZVByb3DTCNSAbbJ2wACqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqhOdWxsUHJvcMCqU3RyaW5nUHJvcKhTaWduYWxSIQ=="),
},
// Completion Messages // Completion Messages
new object[] { new ProtocolTestData(
new ProtocolTestData( name: "CompletionWithNoHeadersAndError",
name: "CompletionWithNoHeadersAndError", message: CompletionMessage.WithError(invocationId: "xyz", error: "Error not found!"),
message: CompletionMessage.WithError(invocationId: "xyz", error: "Error not found!"), encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 1, "Error not found!"),
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 1, "Error not found!"), binary: "lQOAo3h5egGwRXJyb3Igbm90IGZvdW5kIQ=="),
binary: "lQOAo3h5egGwRXJyb3Igbm90IGZvdW5kIQ=="), new ProtocolTestData(
}, name: "CompletionWithHeadersAndError",
new object[] { message: AddHeaders(TestHeaders, CompletionMessage.WithError(invocationId: "xyz", error: "Error not found!")),
new ProtocolTestData( encoded: Array(HubProtocolConstants.CompletionMessageType, TestHeadersSerialized, "xyz", 1, "Error not found!"),
name: "CompletionWithHeadersAndError", binary: "lQODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6AbBFcnJvciBub3QgZm91bmQh"),
message: AddHeaders(TestHeaders, CompletionMessage.WithError(invocationId: "xyz", error: "Error not found!")), new ProtocolTestData(
encoded: Array(HubProtocolConstants.CompletionMessageType, TestHeadersSerialized, "xyz", 1, "Error not found!"), name: "CompletionWithNoHeadersAndNoResult",
binary: "lQODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6AbBFcnJvciBub3QgZm91bmQh"), message: CompletionMessage.Empty(invocationId: "xyz"),
}, encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 2),
new object[] { binary: "lAOAo3h5egI="),
new ProtocolTestData( new ProtocolTestData(
name: "CompletionWithNoHeadersAndNoResult", name: "CompletionWithHeadersAndNoResult",
message: CompletionMessage.Empty(invocationId: "xyz"), message: AddHeaders(TestHeaders, CompletionMessage.Empty(invocationId: "xyz")),
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 2), encoded: Array(HubProtocolConstants.CompletionMessageType, TestHeadersSerialized, "xyz", 2),
binary: "lAOAo3h5egI="), binary: "lAODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6Ag=="),
}, new ProtocolTestData(
new object[] { name: "CompletionWithNoHeadersAndNullResult",
new ProtocolTestData( message: CompletionMessage.WithResult(invocationId: "xyz", payload: null),
name: "CompletionWithHeadersAndNoResult", encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, MessagePackObject.Nil),
message: AddHeaders(TestHeaders, CompletionMessage.Empty(invocationId: "xyz")), binary: "lQOAo3h5egPA"),
encoded: Array(HubProtocolConstants.CompletionMessageType, TestHeadersSerialized, "xyz", 2), new ProtocolTestData(
binary: "lAODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6Ag=="), name: "CompletionWithNoHeadersAndIntResult",
}, message: CompletionMessage.WithResult(invocationId: "xyz", payload: 42),
new object[] { encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, 42),
new ProtocolTestData( binary: "lQOAo3h5egMq"),
name: "CompletionWithNoHeadersAndNullResult", new ProtocolTestData(
message: CompletionMessage.WithResult(invocationId: "xyz", payload: null), name: "CompletionWithNoHeadersAndFloatResult",
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, MessagePackObject.Nil), message: CompletionMessage.WithResult(invocationId: "xyz", payload: 42.0f),
binary: "lQOAo3h5egPA"), encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, 42.0f),
}, binary: "lQOAo3h5egPKQigAAA=="),
new object[] { new ProtocolTestData(
new ProtocolTestData( name: "CompletionWithNoHeadersAndStringResult",
name: "CompletionWithNoHeadersAndIntResult", message: CompletionMessage.WithResult(invocationId: "xyz", payload: "string"),
message: CompletionMessage.WithResult(invocationId: "xyz", payload: 42), encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, "string"),
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, 42), binary: "lQOAo3h5egOmc3RyaW5n"),
binary: "lQOAo3h5egMq"), new ProtocolTestData(
}, name: "CompletionWithNoHeadersAndBooleanResult",
new object[] { message: CompletionMessage.WithResult(invocationId: "xyz", payload: true),
new ProtocolTestData( encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, true),
name: "CompletionWithNoHeadersAndFloatResult", binary: "lQOAo3h5egPD"),
message: CompletionMessage.WithResult(invocationId: "xyz", payload: 42.0f), new ProtocolTestData(
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, 42.0f), name: "CompletionWithNoHeadersAndCustomObjectResult",
binary: "lQOAo3h5egPKQigAAA=="), message: CompletionMessage.WithResult(invocationId: "xyz", payload: new CustomObject()),
}, encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, CustomObjectSerialized),
new object[] { binary: "lQOAo3h5egOGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
new ProtocolTestData( new ProtocolTestData(
name: "CompletionWithNoHeadersAndStringResult", name: "CompletionWithNoHeadersAndCustomObjectArrayResult",
message: CompletionMessage.WithResult(invocationId: "xyz", payload: "string"), message: CompletionMessage.WithResult(invocationId: "xyz", payload: new[] { new CustomObject(), new CustomObject() }),
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, "string"), encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, Array(CustomObjectSerialized, CustomObjectSerialized)),
binary: "lQOAo3h5egOmc3RyaW5n"), binary: "lQOAo3h5egOShqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIhhqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIh"),
}, new ProtocolTestData(
new object[] { name: "CompletionWithHeadersAndCustomObjectArrayResult",
new ProtocolTestData( message: AddHeaders(TestHeaders, CompletionMessage.WithResult(invocationId: "xyz", payload: new[] { new CustomObject(), new CustomObject() })),
name: "CompletionWithNoHeadersAndBooleanResult", encoded: Array(HubProtocolConstants.CompletionMessageType, TestHeadersSerialized, "xyz", 3, Array(CustomObjectSerialized, CustomObjectSerialized)),
message: CompletionMessage.WithResult(invocationId: "xyz", payload: true), binary: "lQODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6A5KGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, true),
binary: "lQOAo3h5egPD"),
},
new object[] {
new ProtocolTestData(
name: "CompletionWithNoHeadersAndCustomObjectResult",
message: CompletionMessage.WithResult(invocationId: "xyz", payload: new CustomObject()),
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, CustomObjectSerialized),
binary: "lQOAo3h5egOGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
},
new object[] {
new ProtocolTestData(
name: "CompletionWithNoHeadersAndCustomObjectArrayResult",
message: CompletionMessage.WithResult(invocationId: "xyz", payload: new[] { new CustomObject(), new CustomObject() }),
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, Array(CustomObjectSerialized, CustomObjectSerialized)),
binary: "lQOAo3h5egOShqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNMI1IBtsnbAAKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIhhqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNMI1IBtsnbAAKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIh"),
},
new object[] {
new ProtocolTestData(
name: "CompletionWithHeadersAndCustomObjectArrayResult",
message: AddHeaders(TestHeaders, CompletionMessage.WithResult(invocationId: "xyz", payload: new[] { new CustomObject(), new CustomObject() })),
encoded: Array(HubProtocolConstants.CompletionMessageType, TestHeadersSerialized, "xyz", 3, Array(CustomObjectSerialized, CustomObjectSerialized)),
binary: "lQODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6A5KGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
},
// StreamInvocation Messages // StreamInvocation Messages
new object[] { new ProtocolTestData(
new ProtocolTestData( name: "StreamInvocationWithNoHeadersAndNoArgs",
name: "StreamInvocationWithNoHeadersAndNoArgs", message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null),
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null), encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array()),
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array()), binary: "lQSAo3h5eqZtZXRob2SQ"),
binary: "lQSAo3h5eqZtZXRob2SQ"), new ProtocolTestData(
}, name: "StreamInvocationWithNoHeadersAndNullArg",
new object[] { message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new object[] { null }),
new ProtocolTestData( encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(MessagePackObject.Nil)),
name: "StreamInvocationWithNoHeadersAndNullArg", binary: "lQSAo3h5eqZtZXRob2SRwA=="),
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new object[] { null }), new ProtocolTestData(
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(MessagePackObject.Nil)), name: "StreamInvocationWithNoHeadersAndIntArg",
binary: "lQSAo3h5eqZtZXRob2SRwA=="), message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42),
}, encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42)),
new object[] { binary: "lQSAo3h5eqZtZXRob2SRKg=="),
new ProtocolTestData( new ProtocolTestData(
name: "StreamInvocationWithNoHeadersAndIntArg", name: "StreamInvocationWithNoHeadersAndIntAndStringArgs",
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42), message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42, "string"),
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42)), encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42, "string")),
binary: "lQSAo3h5eqZtZXRob2SRKg=="), binary: "lQSAo3h5eqZtZXRob2SSKqZzdHJpbmc="),
}, new ProtocolTestData(
new object[] { name: "StreamInvocationWithNoHeadersAndIntStringAndCustomObjectArgs",
new ProtocolTestData( message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42, "string", new CustomObject()),
name: "StreamInvocationWithNoHeadersAndIntAndStringArgs", encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42, "string", CustomObjectSerialized)),
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42, "string"), binary: "lQSAo3h5eqZtZXRob2STKqZzdHJpbmeGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42, "string")), new ProtocolTestData(
binary: "lQSAo3h5eqZtZXRob2SSKqZzdHJpbmc="), name: "StreamInvocationWithNoHeadersAndCustomObjectArrayArg",
}, message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() }),
new object[] { encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(CustomObjectSerialized, CustomObjectSerialized)),
new ProtocolTestData( binary: "lQSAo3h5eqZtZXRob2SShqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIhhqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIh"),
name: "StreamInvocationWithNoHeadersAndIntStringAndCustomObjectArgs", new ProtocolTestData(
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42, "string", new CustomObject()), name: "StreamInvocationWithHeadersAndCustomObjectArrayArg",
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42, "string", CustomObjectSerialized)), message: AddHeaders(TestHeaders, new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() })),
binary: "lQSAo3h5eqZtZXRob2STKqZzdHJpbmeGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="), encoded: Array(HubProtocolConstants.StreamInvocationMessageType, TestHeadersSerialized, "xyz", "method", Array(CustomObjectSerialized, CustomObjectSerialized)),
}, binary: "lQSDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6pm1ldGhvZJKGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
new object[] {
new ProtocolTestData(
name: "StreamInvocationWithNoHeadersAndCustomObjectArrayArg",
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() }),
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(CustomObjectSerialized, CustomObjectSerialized)),
binary: "lQSAo3h5eqZtZXRob2SShqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNMI1IBtsnbAAKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIhhqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNMI1IBtsnbAAKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIh"),
},
new object[] {
new ProtocolTestData(
name: "StreamInvocationWithHeadersAndCustomObjectArrayArg",
message: AddHeaders(TestHeaders, new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() })),
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, TestHeadersSerialized, "xyz", "method", Array(CustomObjectSerialized, CustomObjectSerialized)),
binary: "lQSDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6pm1ldGhvZJKGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
},
// CancelInvocation Messages // CancelInvocation Messages
new object[] { new ProtocolTestData(
new ProtocolTestData( name: "CancelInvocationWithNoHeaders",
name: "CancelInvocationWithNoHeaders", message: new CancelInvocationMessage(invocationId: "xyz"),
message: new CancelInvocationMessage(invocationId: "xyz"), encoded: Array(HubProtocolConstants.CancelInvocationMessageType, Map(), "xyz"),
encoded: Array(HubProtocolConstants.CancelInvocationMessageType, Map(), "xyz"), binary: "kwWAo3h5eg=="),
binary: "kwWAo3h5eg=="), new ProtocolTestData(
}, name: "CancelInvocationWithHeaders",
new object[] { message: AddHeaders(TestHeaders, new CancelInvocationMessage(invocationId: "xyz")),
new ProtocolTestData( encoded: Array(HubProtocolConstants.CancelInvocationMessageType, TestHeadersSerialized, "xyz"),
name: "CancelInvocationWithHeaders", binary: "kwWDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6"),
message: AddHeaders(TestHeaders, new CancelInvocationMessage(invocationId: "xyz")),
encoded: Array(HubProtocolConstants.CancelInvocationMessageType, TestHeadersSerialized, "xyz"),
binary: "kwWDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6"),
},
// Ping Messages // Ping Messages
new object[] { new ProtocolTestData(
new ProtocolTestData( name: "Ping",
name: "Ping", message: PingMessage.Instance,
message: PingMessage.Instance, encoded: Array(HubProtocolConstants.PingMessageType),
encoded: Array(HubProtocolConstants.PingMessageType), binary: "kQY="),
binary: "kQY="), }.ToDictionary(t => t.Name);
},
};
[Theory] [Theory]
[MemberData(nameof(TestData))] [MemberData(nameof(TestDataNames))]
public void ParseMessages(ProtocolTestData testData) public void ParseMessages(string testDataName)
{ {
var testData = TestData[testDataName];
// Verify that the input binary string decodes to the expected MsgPack primitives // Verify that the input binary string decodes to the expected MsgPack primitives
var bytes = Convert.FromBase64String(testData.Binary); var bytes = Convert.FromBase64String(testData.Binary);
var obj = Unpack(bytes); var obj = Unpack(bytes);
@ -357,9 +294,11 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
} }
[Theory] [Theory]
[MemberData(nameof(TestData))] [MemberData(nameof(TestDataNames))]
public void WriteMessages(ProtocolTestData testData) public void WriteMessages(string testDataName)
{ {
var testData = TestData[testDataName];
var bytes = Write(testData.Message); var bytes = Write(testData.Message);
AssertMessages(testData.Encoded, bytes); AssertMessages(testData.Encoded, bytes);