SignalR 281 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. commit 13757936ad56a9b88fcdcde489380ca77f025096
  2. Author: Pawel Kadluczka <[email protected]>
  3. Date: Wed Nov 1 16:40:02 2017 -0700
  4. Adding roundtripping test for GUID property
  5. diff --git a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/ComplexObject.cs b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/ComplexObject.cs
  6. index 8624b6d2460..7ae481c3488 100644
  7. --- a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/ComplexObject.cs
  8. +++ b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/ComplexObject.cs
  9. @@ -1,6 +1,8 @@
  10. // Copyright (c) .NET Foundation. All rights reserved.
  11. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  12. +using System;
  13. +
  14. namespace Microsoft.AspNetCore.SignalR.Test.Server
  15. {
  16. public class ComplexObject
  17. @@ -8,5 +10,6 @@ namespace Microsoft.AspNetCore.SignalR.Test.Server
  18. public string String { get; set; }
  19. public int[] IntArray { get; set; }
  20. public byte[] ByteArray { get; set; }
  21. + public Guid GUID { get; set; }
  22. }
  23. }
  24. \ No newline at end of file
  25. 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
  26. index 84eadbbc975..68d46989596 100644
  27. --- a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/wwwroot/js/hubConnectionTests.js
  28. +++ b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/wwwroot/js/hubConnectionTests.js
  29. @@ -301,17 +301,30 @@ describe('hubConnection', function () {
  30. IntArray: [0x01, 0x02, 0x03, 0xff],
  31. ByteArray: protocol.name == "json"
  32. ? btoa([0xff, 0x03, 0x02, 0x01])
  33. - : new Uint8Array([0xff, 0x03, 0x02, 0x01])
  34. + : new Uint8Array([0xff, 0x03, 0x02, 0x01]),
  35. + GUID: protocol.name == "json"
  36. + ? "00010203-0405-0607-0706-050403020100"
  37. + : new Uint8Array([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00])
  38. };
  39. hubConnection.start().then(function () {
  40. return hubConnection.invoke('EchoComplexObject', complexObject);
  41. })
  42. .then(function (value) {
  43. - // msgpack creates a Buffer for byte arrays and jasmine fails to compare a Buffer
  44. - // and a Uint8Array even though Buffer instances are also Uint8Array instances
  45. if (protocol.name == "messagepack") {
  46. + // msgpack creates a Buffer for byte arrays and jasmine fails to compare a Buffer
  47. + // and a Uint8Array even though Buffer instances are also Uint8Array instances
  48. value.ByteArray = new Uint8Array(value.ByteArray);
  49. +
  50. + // GUIDs are serialized as raw type which is a string containing bytes which need to
  51. + // be extracted. Note that with msgpack5 the original bytes will be encoded with utf8
  52. + // and needs to be decoded. To not go into utf8 encoding intricacies the test uses values
  53. + // less than 0x80.
  54. + let guidBytes = [];
  55. + for (let i = 0; i < value.GUID.length; i++) {
  56. + guidBytes.push(value.GUID.charCodeAt(i));
  57. + }
  58. + value.GUID = new Uint8Array(guidBytes);
  59. }
  60. expect(value).toEqual(complexObject);
  61. })