parent
c8d4cf689f
commit
b3a33efeae
|
|
@ -56,7 +56,7 @@
|
|||
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview2-26130-04</MicrosoftNETCoreApp21PackageVersion>
|
||||
<MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion>
|
||||
<MoqPackageVersion>4.7.49</MoqPackageVersion>
|
||||
<MsgPackCliPackageVersion>0.9.0-beta2</MsgPackCliPackageVersion>
|
||||
<MsgPackCliPackageVersion>1.0.0-rc</MsgPackCliPackageVersion>
|
||||
<NewtonsoftJsonPackageVersion>10.0.1</NewtonsoftJsonPackageVersion>
|
||||
<StackExchangeRedisStrongNamePackageVersion>1.2.4</StackExchangeRedisStrongNamePackageVersion>
|
||||
<SystemBuffersPackageVersion>4.5.0-preview2-26130-01</SystemBuffersPackageVersion>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
"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: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"
|
||||
},
|
||||
"keywords": [
|
||||
|
|
|
|||
|
|
@ -1,111 +1,139 @@
|
|||
// 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.
|
||||
|
||||
import { MessagePackHubProtocol } from "../src/MessagePackHubProtocol"
|
||||
import { MessageType, InvocationMessage, CompletionMessage, StreamItemMessage } from "@aspnet/signalr"
|
||||
import { CompletionMessage, InvocationMessage, MessageType, StreamItemMessage } from "@aspnet/signalr";
|
||||
import { MessagePackHubProtocol } from "../src/MessagePackHubProtocol";
|
||||
|
||||
describe("MessageHubProtocol", () => {
|
||||
it("can write/read non-blocking Invocation message", () => {
|
||||
let invocation = <InvocationMessage>{
|
||||
const invocation = {
|
||||
arguments: [42, true, "test", ["x1", "y2"], null],
|
||||
headers: {},
|
||||
type: MessageType.Invocation,
|
||||
target: "myMethod",
|
||||
arguments: [42, true, "test", ["x1", "y2"], null]
|
||||
};
|
||||
type: MessageType.Invocation,
|
||||
} as InvocationMessage;
|
||||
|
||||
let protocol = new MessagePackHubProtocol();
|
||||
var parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation));
|
||||
const protocol = new MessagePackHubProtocol();
|
||||
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]);
|
||||
});
|
||||
|
||||
it("can write/read Invocation message with headers", () => {
|
||||
let invocation = <InvocationMessage>{
|
||||
const invocation = {
|
||||
arguments: [42, true, "test", ["x1", "y2"], null],
|
||||
headers: {
|
||||
"foo": "bar"
|
||||
foo: "bar",
|
||||
},
|
||||
type: MessageType.Invocation,
|
||||
target: "myMethod",
|
||||
arguments: [42, true, "test", ["x1", "y2"], null]
|
||||
};
|
||||
type: MessageType.Invocation,
|
||||
} as InvocationMessage;
|
||||
|
||||
let protocol = new MessagePackHubProtocol();
|
||||
var parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation));
|
||||
const protocol = new MessagePackHubProtocol();
|
||||
const parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation));
|
||||
expect(parsedMessages).toEqual([invocation]);
|
||||
});
|
||||
|
||||
it("can write/read Invocation message", () => {
|
||||
let invocation = <InvocationMessage>{
|
||||
const invocation = {
|
||||
arguments: [42, true, "test", ["x1", "y2"], null],
|
||||
headers: {},
|
||||
type: MessageType.Invocation,
|
||||
invocationId: "123",
|
||||
target: "myMethod",
|
||||
arguments: [42, true, "test", ["x1", "y2"], null]
|
||||
};
|
||||
type: MessageType.Invocation,
|
||||
} as InvocationMessage;
|
||||
|
||||
let protocol = new MessagePackHubProtocol();
|
||||
var parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation));
|
||||
const protocol = new MessagePackHubProtocol();
|
||||
const parsedMessages = protocol.parseMessages(protocol.writeMessage(invocation));
|
||||
expect(parsedMessages).toEqual([invocation]);
|
||||
});
|
||||
|
||||
([
|
||||
[[0x0c, 0x95, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x01, 0xa3, 0x45, 0x72, 0x72],
|
||||
{
|
||||
headers: {},
|
||||
type: MessageType.Completion,
|
||||
invocationId: "abc",
|
||||
error: "Err",
|
||||
result: null
|
||||
headers: {},
|
||||
invocationId: "abc",
|
||||
result: null,
|
||||
type: MessageType.Completion,
|
||||
} as CompletionMessage],
|
||||
[[0x0b, 0x95, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x03, 0xa2, 0x4f, 0x4b],
|
||||
{
|
||||
headers: {},
|
||||
type: MessageType.Completion,
|
||||
invocationId: "abc",
|
||||
error: null,
|
||||
result: "OK"
|
||||
headers: {},
|
||||
invocationId: "abc",
|
||||
result: "OK",
|
||||
type: MessageType.Completion,
|
||||
} as CompletionMessage],
|
||||
[[0x08, 0x94, 0x03, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x02],
|
||||
{
|
||||
headers: {},
|
||||
type: MessageType.Completion,
|
||||
invocationId: "abc",
|
||||
error: null,
|
||||
result: null
|
||||
} as CompletionMessage]
|
||||
] as [number[], CompletionMessage][]).forEach(([payload, expected_message]) =>
|
||||
headers: {},
|
||||
invocationId: "abc",
|
||||
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", () => {
|
||||
let messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
|
||||
expect(messages).toEqual([expected_message]);
|
||||
const messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
|
||||
expect(messages).toEqual([expectedMessage]);
|
||||
}));
|
||||
|
||||
([
|
||||
[[0x08, 0x94, 0x02, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x08],
|
||||
{
|
||||
headers: {},
|
||||
type: MessageType.StreamItem,
|
||||
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 [[number[], StreamItemMessage]]).forEach(([payload, expected_message]) =>
|
||||
] as Array<[number[], StreamItemMessage]>).forEach(([payload, expectedMessage]) =>
|
||||
it("can read StreamItem message", () => {
|
||||
let messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
|
||||
expect(messages).toEqual([expected_message]);
|
||||
const messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
|
||||
expect(messages).toEqual([expectedMessage]);
|
||||
}));
|
||||
|
||||
([
|
||||
[[0x0c, 0x94, 0x02, 0x81, 0xa1, 0x74, 0xa1, 0x75, 0xa3, 0x61, 0x62, 0x63, 0x08],
|
||||
{
|
||||
headers: {
|
||||
"t": "u"
|
||||
t: "u",
|
||||
},
|
||||
type: MessageType.StreamItem,
|
||||
invocationId: "abc",
|
||||
item: 8
|
||||
} as StreamItemMessage]
|
||||
] as [[number[], StreamItemMessage]]).forEach(([payload, expected_message]) =>
|
||||
item: 8,
|
||||
type: MessageType.StreamItem,
|
||||
} as StreamItemMessage],
|
||||
] as Array<[number[], StreamItemMessage]>).forEach(([payload, expectedMessage]) =>
|
||||
it("can read message with headers", () => {
|
||||
let messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
|
||||
expect(messages).toEqual([expected_message]);
|
||||
const messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
|
||||
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 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 error", [0x05, 0x94, 0x03, 0x80, 0xa0, 0x03], new Error("Invalid payload for Completion message.")]
|
||||
] as [string, number[], Error][]).forEach(([name, payload, expected_error]) =>
|
||||
["Completion message with missing error", [0x05, 0x94, 0x03, 0x80, 0xa0, 0x03], new Error("Invalid payload for Completion message.")],
|
||||
] as Array<[string, number[], Error]>).forEach(([name, payload, expectedError]) =>
|
||||
it("throws for " + name, () => {
|
||||
expect(() => new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer))
|
||||
.toThrow(expected_error);
|
||||
.toThrow(expectedError);
|
||||
}));
|
||||
|
||||
it("can read multiple messages", () => {
|
||||
let payload = [
|
||||
const payload = [
|
||||
0x08, 0x94, 0x02, 0x80, 0xa3, 0x61, 0x62, 0x63, 0x08,
|
||||
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([
|
||||
{
|
||||
headers: {},
|
||||
type: MessageType.StreamItem,
|
||||
invocationId: "abc",
|
||||
item: 8
|
||||
item: 8,
|
||||
type: MessageType.StreamItem,
|
||||
} as StreamItemMessage,
|
||||
{
|
||||
headers: {},
|
||||
type: MessageType.Completion,
|
||||
invocationId: "abc",
|
||||
error: null,
|
||||
result: "OK"
|
||||
} as CompletionMessage
|
||||
headers: {},
|
||||
invocationId: "abc",
|
||||
result: "OK",
|
||||
type: MessageType.Completion,
|
||||
} as CompletionMessage,
|
||||
]);
|
||||
});
|
||||
|
||||
it("can read ping message", () => {
|
||||
let payload = [
|
||||
const payload = [
|
||||
0x02,
|
||||
0x91, // message array length = 1 (fixarray)
|
||||
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([
|
||||
{
|
||||
type: MessageType.Ping,
|
||||
}
|
||||
])
|
||||
})
|
||||
});
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
"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: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"
|
||||
},
|
||||
"repository": {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
"compilerOptions": {
|
||||
"module": "es2015",
|
||||
"target": "es2016",
|
||||
"outDir": "./obj/js",
|
||||
"sourceMap": true,
|
||||
"moduleResolution": "node",
|
||||
"inlineSources": true,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<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.Sockets.Http\Microsoft.AspNetCore.Sockets.Http.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-protocol-msgpack\dist\browser\*" />
|
||||
</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>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ using System;
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using MsgPack.Serialization;
|
||||
using SocketsSample.EndPoints;
|
||||
using SocketsSample.Hubs;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace SocketsSample
|
||||
{
|
||||
|
|
@ -23,6 +24,10 @@ namespace SocketsSample
|
|||
{
|
||||
// Faster pings for testing
|
||||
options.KeepAliveInterval = TimeSpan.FromSeconds(5);
|
||||
})
|
||||
.AddMessagePackProtocol(options =>
|
||||
{
|
||||
options.SerializationContext.DictionarySerlaizationOptions.KeyTransformer = DictionaryKeyTransformers.LowerCamel;
|
||||
});
|
||||
// .AddRedis();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
|
@ -7,11 +7,23 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<h1 id="head1"></h1>
|
||||
<h1 id="head1">SignalR Hubs Sample</h1>
|
||||
<div>
|
||||
<select id="formatType">
|
||||
<option value="json">json</option>
|
||||
<option value="line">line</option>
|
||||
<select id="protocol">
|
||||
<option value="json" selected>json</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<T></option>
|
||||
</select>
|
||||
|
||||
<input type="button" id="connect" value="Connect" />
|
||||
|
|
@ -62,7 +74,9 @@
|
|||
</body>
|
||||
|
||||
</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>
|
||||
var isConnected = false;
|
||||
|
|
@ -88,12 +102,7 @@
|
|||
return document.getElementById(id).value;
|
||||
}
|
||||
|
||||
let transportType = signalR.TransportType[getParameterByName('transport')] || signalR.TransportType.WebSockets;
|
||||
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 disconnectButton = document.getElementById('disconnect');
|
||||
|
|
@ -105,6 +114,9 @@
|
|||
let groupMsgButton = document.getElementById('groupmsg');
|
||||
let othersGroupMsgButton = document.getElementById('others-groupmsg');
|
||||
let sendButton = document.getElementById('send');
|
||||
let protocolDropdown = document.getElementById('protocol');
|
||||
let transportDropdown = document.getElementById('transport');
|
||||
let hubTypeDropdown = document.getElementById('hubType');
|
||||
|
||||
function updateButtonState(isConnected) {
|
||||
broadcastButton.disabled = !isConnected;
|
||||
|
|
@ -123,8 +135,14 @@
|
|||
var connection;
|
||||
|
||||
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);
|
||||
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) {
|
||||
addLine('message-list', msg);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
|
@ -14,21 +14,7 @@
|
|||
</ul>
|
||||
<h1>ASP.NET Core SignalR (Hubs)</h1>
|
||||
<ul>
|
||||
<li><a href="hubs.html?transport=LongPolling">Long polling</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<T>)</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>
|
||||
<li><a href="hubs.html">Hubs</a></li>
|
||||
</ul>
|
||||
<h1>ASP.NET Core SignalR (Streaming)</h1>
|
||||
<ul>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
</form>
|
||||
|
||||
<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>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
<ul id="resultsList"></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>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,11 @@ using Microsoft.AspNetCore.SignalR.Internal.Formatters;
|
|||
using Microsoft.AspNetCore.SignalR.Internal.Protocol;
|
||||
using MsgPack;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
||||
{
|
||||
using static MessagePackHelpers;
|
||||
using static HubMessageHelpers;
|
||||
using static MessagePackHelpers;
|
||||
|
||||
public class MessagePackHubProtocolTests
|
||||
{
|
||||
|
|
@ -36,7 +35,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
|||
|
||||
private static MessagePackObject CustomObjectSerialized = Map(
|
||||
("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),
|
||||
("IntProp", 42),
|
||||
("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
|
||||
// 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.
|
||||
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
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersAndNoArgs",
|
||||
message: new InvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), "xyz", "method", Array()),
|
||||
binary: "lQGAo3h5eqZtZXRob2SQ"),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndNoArgs",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array()),
|
||||
binary: "lQGAwKZtZXRob2SQ"),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndSingleNullArg",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, new object[] { null }),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(MessagePackObject.Nil)),
|
||||
binary: "lQGAwKZtZXRob2SRwA=="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndSingleIntArg",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, 42),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42)),
|
||||
binary: "lQGAwKZtZXRob2SRKg=="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdIntAndStringArgs",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, 42, "string"),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42, "string")),
|
||||
binary: "lQGAwKZtZXRob2SSKqZzdHJpbmc="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndCustomObjectArg",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, 42, "string", new CustomObject()),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42, "string", CustomObjectSerialized)),
|
||||
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="),
|
||||
},
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersAndNoArgs",
|
||||
message: new InvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), "xyz", "method", Array()),
|
||||
binary: "lQGAo3h5eqZtZXRob2SQ"),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndNoArgs",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array()),
|
||||
binary: "lQGAwKZtZXRob2SQ"),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndSingleNullArg",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, new object[] { null }),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(MessagePackObject.Nil)),
|
||||
binary: "lQGAwKZtZXRob2SRwA=="),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndSingleIntArg",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, 42),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42)),
|
||||
binary: "lQGAwKZtZXRob2SRKg=="),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdIntAndStringArgs",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, 42, "string"),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42, "string")),
|
||||
binary: "lQGAwKZtZXRob2SSKqZzdHJpbmc="),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndCustomObjectArg",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, 42, "string", new CustomObject()),
|
||||
encoded: Array(HubProtocolConstants.InvocationMessageType, Map(), MessagePackObject.Nil, "method", Array(42, "string", CustomObjectSerialized)),
|
||||
binary: "lQGAwKZtZXRob2STKqZzdHJpbmeGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
|
||||
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: "lQGAwKZtZXRob2SShqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIhhqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIh"),
|
||||
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: "lQGDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmXApm1ldGhvZJKGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
|
||||
|
||||
// StreamItem Messages
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndNullItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: null),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", MessagePackObject.Nil),
|
||||
binary: "lAKAo3h5esA="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndIntItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: 42),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", 42),
|
||||
binary: "lAKAo3h5eio="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndFloatItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: 42.0f),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", 42.0f),
|
||||
binary: "lAKAo3h5espCKAAA"),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndStringItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: "string"),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", "string"),
|
||||
binary: "lAKAo3h5eqZzdHJpbmc="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndBoolItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: true),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", true),
|
||||
binary: "lAKAo3h5esM="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndCustomObjectItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: new CustomObject()),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", CustomObjectSerialized),
|
||||
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=="),
|
||||
},
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndNullItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: null),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", MessagePackObject.Nil),
|
||||
binary: "lAKAo3h5esA="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndIntItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: 42),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", 42),
|
||||
binary: "lAKAo3h5eio="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndFloatItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: 42.0f),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", 42.0f),
|
||||
binary: "lAKAo3h5espCKAAA"),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndStringItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: "string"),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", "string"),
|
||||
binary: "lAKAo3h5eqZzdHJpbmc="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndBoolItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: true),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", true),
|
||||
binary: "lAKAo3h5esM="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndCustomObjectItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: new CustomObject()),
|
||||
encoded: Array(HubProtocolConstants.StreamItemMessageType, Map(), "xyz", CustomObjectSerialized),
|
||||
binary: "lAKAo3h5eoarQnl0ZUFyclByb3DEAwECA6xEYXRlVGltZVByb3DW/1jsHICqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqhOdWxsUHJvcMCqU3RyaW5nUHJvcKhTaWduYWxSIQ=="),
|
||||
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: "lAKAo3h5epKGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
|
||||
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: "lAKDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6koarQnl0ZUFyclByb3DEAwECA6xEYXRlVGltZVByb3DW/1jsHICqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqhOdWxsUHJvcMCqU3RyaW5nUHJvcKhTaWduYWxSIYarQnl0ZUFyclByb3DEAwECA6xEYXRlVGltZVByb3DW/1jsHICqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqhOdWxsUHJvcMCqU3RyaW5nUHJvcKhTaWduYWxSIQ=="),
|
||||
|
||||
// Completion Messages
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndError",
|
||||
message: CompletionMessage.WithError(invocationId: "xyz", error: "Error not found!"),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 1, "Error not found!"),
|
||||
binary: "lQOAo3h5egGwRXJyb3Igbm90IGZvdW5kIQ=="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithHeadersAndError",
|
||||
message: AddHeaders(TestHeaders, CompletionMessage.WithError(invocationId: "xyz", error: "Error not found!")),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, TestHeadersSerialized, "xyz", 1, "Error not found!"),
|
||||
binary: "lQODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6AbBFcnJvciBub3QgZm91bmQh"),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndNoResult",
|
||||
message: CompletionMessage.Empty(invocationId: "xyz"),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 2),
|
||||
binary: "lAOAo3h5egI="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithHeadersAndNoResult",
|
||||
message: AddHeaders(TestHeaders, CompletionMessage.Empty(invocationId: "xyz")),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, TestHeadersSerialized, "xyz", 2),
|
||||
binary: "lAODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6Ag=="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndNullResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: null),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, MessagePackObject.Nil),
|
||||
binary: "lQOAo3h5egPA"),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndIntResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: 42),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, 42),
|
||||
binary: "lQOAo3h5egMq"),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndFloatResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: 42.0f),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, 42.0f),
|
||||
binary: "lQOAo3h5egPKQigAAA=="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndStringResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: "string"),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, "string"),
|
||||
binary: "lQOAo3h5egOmc3RyaW5n"),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndBooleanResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: true),
|
||||
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="),
|
||||
},
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndError",
|
||||
message: CompletionMessage.WithError(invocationId: "xyz", error: "Error not found!"),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 1, "Error not found!"),
|
||||
binary: "lQOAo3h5egGwRXJyb3Igbm90IGZvdW5kIQ=="),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithHeadersAndError",
|
||||
message: AddHeaders(TestHeaders, CompletionMessage.WithError(invocationId: "xyz", error: "Error not found!")),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, TestHeadersSerialized, "xyz", 1, "Error not found!"),
|
||||
binary: "lQODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6AbBFcnJvciBub3QgZm91bmQh"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndNoResult",
|
||||
message: CompletionMessage.Empty(invocationId: "xyz"),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 2),
|
||||
binary: "lAOAo3h5egI="),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithHeadersAndNoResult",
|
||||
message: AddHeaders(TestHeaders, CompletionMessage.Empty(invocationId: "xyz")),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, TestHeadersSerialized, "xyz", 2),
|
||||
binary: "lAODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6Ag=="),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndNullResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: null),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, MessagePackObject.Nil),
|
||||
binary: "lQOAo3h5egPA"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndIntResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: 42),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, 42),
|
||||
binary: "lQOAo3h5egMq"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndFloatResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: 42.0f),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, 42.0f),
|
||||
binary: "lQOAo3h5egPKQigAAA=="),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndStringResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: "string"),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, "string"),
|
||||
binary: "lQOAo3h5egOmc3RyaW5n"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndBooleanResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: true),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, true),
|
||||
binary: "lQOAo3h5egPD"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndCustomObjectResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: new CustomObject()),
|
||||
encoded: Array(HubProtocolConstants.CompletionMessageType, Map(), "xyz", 3, CustomObjectSerialized),
|
||||
binary: "lQOAo3h5egOGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
|
||||
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: "lQOAo3h5egOShqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIhhqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIh"),
|
||||
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: "lQODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6A5KGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
|
||||
|
||||
// StreamInvocation Messages
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndNoArgs",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null),
|
||||
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array()),
|
||||
binary: "lQSAo3h5eqZtZXRob2SQ"),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndNullArg",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new object[] { null }),
|
||||
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(MessagePackObject.Nil)),
|
||||
binary: "lQSAo3h5eqZtZXRob2SRwA=="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndIntArg",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42),
|
||||
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42)),
|
||||
binary: "lQSAo3h5eqZtZXRob2SRKg=="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndIntAndStringArgs",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42, "string"),
|
||||
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42, "string")),
|
||||
binary: "lQSAo3h5eqZtZXRob2SSKqZzdHJpbmc="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndIntStringAndCustomObjectArgs",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42, "string", new CustomObject()),
|
||||
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42, "string", CustomObjectSerialized)),
|
||||
binary: "lQSAo3h5eqZtZXRob2STKqZzdHJpbmeGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w0wjUgG2ydsAAqkRvdWJsZVByb3DLQBkh+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="),
|
||||
},
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndNoArgs",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null),
|
||||
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array()),
|
||||
binary: "lQSAo3h5eqZtZXRob2SQ"),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndNullArg",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new object[] { null }),
|
||||
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(MessagePackObject.Nil)),
|
||||
binary: "lQSAo3h5eqZtZXRob2SRwA=="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndIntArg",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42),
|
||||
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42)),
|
||||
binary: "lQSAo3h5eqZtZXRob2SRKg=="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndIntAndStringArgs",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42, "string"),
|
||||
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42, "string")),
|
||||
binary: "lQSAo3h5eqZtZXRob2SSKqZzdHJpbmc="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndIntStringAndCustomObjectArgs",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42, "string", new CustomObject()),
|
||||
encoded: Array(HubProtocolConstants.StreamInvocationMessageType, Map(), "xyz", "method", Array(42, "string", CustomObjectSerialized)),
|
||||
binary: "lQSAo3h5eqZtZXRob2STKqZzdHJpbmeGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
|
||||
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: "lQSAo3h5eqZtZXRob2SShqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIhhqtCeXRlQXJyUHJvcMQDAQIDrERhdGVUaW1lUHJvcNb/WOwcgKpEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqqE51bGxQcm9wwKpTdHJpbmdQcm9wqFNpZ25hbFIh"),
|
||||
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: "lQSDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6pm1ldGhvZJKGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiGGq0J5dGVBcnJQcm9wxAMBAgOsRGF0ZVRpbWVQcm9w1v9Y7ByAqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqoTnVsbFByb3DAqlN0cmluZ1Byb3CoU2lnbmFsUiE="),
|
||||
|
||||
// CancelInvocation Messages
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CancelInvocationWithNoHeaders",
|
||||
message: new CancelInvocationMessage(invocationId: "xyz"),
|
||||
encoded: Array(HubProtocolConstants.CancelInvocationMessageType, Map(), "xyz"),
|
||||
binary: "kwWAo3h5eg=="),
|
||||
},
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "CancelInvocationWithHeaders",
|
||||
message: AddHeaders(TestHeaders, new CancelInvocationMessage(invocationId: "xyz")),
|
||||
encoded: Array(HubProtocolConstants.CancelInvocationMessageType, TestHeadersSerialized, "xyz"),
|
||||
binary: "kwWDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6"),
|
||||
},
|
||||
new ProtocolTestData(
|
||||
name: "CancelInvocationWithNoHeaders",
|
||||
message: new CancelInvocationMessage(invocationId: "xyz"),
|
||||
encoded: Array(HubProtocolConstants.CancelInvocationMessageType, Map(), "xyz"),
|
||||
binary: "kwWAo3h5eg=="),
|
||||
new ProtocolTestData(
|
||||
name: "CancelInvocationWithHeaders",
|
||||
message: AddHeaders(TestHeaders, new CancelInvocationMessage(invocationId: "xyz")),
|
||||
encoded: Array(HubProtocolConstants.CancelInvocationMessageType, TestHeadersSerialized, "xyz"),
|
||||
binary: "kwWDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6"),
|
||||
|
||||
// Ping Messages
|
||||
new object[] {
|
||||
new ProtocolTestData(
|
||||
name: "Ping",
|
||||
message: PingMessage.Instance,
|
||||
encoded: Array(HubProtocolConstants.PingMessageType),
|
||||
binary: "kQY="),
|
||||
},
|
||||
};
|
||||
new ProtocolTestData(
|
||||
name: "Ping",
|
||||
message: PingMessage.Instance,
|
||||
encoded: Array(HubProtocolConstants.PingMessageType),
|
||||
binary: "kQY="),
|
||||
}.ToDictionary(t => t.Name);
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(TestData))]
|
||||
public void ParseMessages(ProtocolTestData testData)
|
||||
[MemberData(nameof(TestDataNames))]
|
||||
public void ParseMessages(string testDataName)
|
||||
{
|
||||
var testData = TestData[testDataName];
|
||||
|
||||
// Verify that the input binary string decodes to the expected MsgPack primitives
|
||||
var bytes = Convert.FromBase64String(testData.Binary);
|
||||
var obj = Unpack(bytes);
|
||||
|
|
@ -357,9 +294,11 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(TestData))]
|
||||
public void WriteMessages(ProtocolTestData testData)
|
||||
[MemberData(nameof(TestDataNames))]
|
||||
public void WriteMessages(string testDataName)
|
||||
{
|
||||
var testData = TestData[testDataName];
|
||||
|
||||
var bytes = Write(testData.Message);
|
||||
AssertMessages(testData.Encoded, bytes);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue