From 1d2e0fedb0c38e5189436d4f821a863140434347 Mon Sep 17 00:00:00 2001 From: moozzyk Date: Tue, 31 Oct 2017 20:20:11 -0700 Subject: [PATCH] Enabling byte[] --- .../ComplexObject.cs | 2 +- .../wwwroot/js/hubConnectionTests.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/ComplexObject.cs b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/ComplexObject.cs index 29a84f4555..8624b6d246 100644 --- a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/ComplexObject.cs +++ b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/ComplexObject.cs @@ -7,6 +7,6 @@ namespace Microsoft.AspNetCore.SignalR.Test.Server { public string String { get; set; } public int[] IntArray { get; set; } - // TODO: byte[] currently doesn't roundtrip for msgpack. See: https://github.com/aspnet/SignalR/issues/945#issuecomment-333260762 + public byte[] ByteArray { get; set; } } } \ No newline at end of file diff --git a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/wwwroot/js/hubConnectionTests.js b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/wwwroot/js/hubConnectionTests.js index 6f4590bd42..84eadbbc97 100644 --- a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/wwwroot/js/hubConnectionTests.js +++ b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/wwwroot/js/hubConnectionTests.js @@ -298,13 +298,21 @@ describe('hubConnection', function () { var complexObject = { String: 'Hello, World!', - IntArray: [0x01, 0x02, 0x03, 0xff] + IntArray: [0x01, 0x02, 0x03, 0xff], + ByteArray: protocol.name == "json" + ? btoa([0xff, 0x03, 0x02, 0x01]) + : new Uint8Array([0xff, 0x03, 0x02, 0x01]) }; hubConnection.start().then(function () { return hubConnection.invoke('EchoComplexObject', complexObject); }) - .then(function(value) { + .then(function (value) { + // msgpack creates a Buffer for byte arrays and jasmine fails to compare a Buffer + // and a Uint8Array even though Buffer instances are also Uint8Array instances + if (protocol.name == "messagepack") { + value.ByteArray = new Uint8Array(value.ByteArray); + } expect(value).toEqual(complexObject); }) .then(function () {