public void GlobalSupportedProtocolsOverriddenByHubSupportedProtocols()
        {
            var testData = _invocationTestData["Single supported protocol"];

            var resolver = CreateHubProtocolResolver(new List <IHubProtocol> {
                new MessagePackHubProtocol(), new JsonHubProtocol()
            });

            var serializer = new DefaultHubMessageSerializer(resolver, new List <string>()
            {
                "json"
            }, new List <string>()
            {
                "messagepack"
            });
            var serializedHubMessage = serializer.SerializeMessage(_testMessage);

            Assert.Equal(1, serializedHubMessage.Count);

            Assert.Equal(new List <byte>()
            {
                0x0D,
                0x96,
                0x01,
                0x80,
                0xC0,
                0xA6, (byte)'t', (byte)'a', (byte)'r', (byte)'g', (byte)'e', (byte)'t',
                0x90,
                0x90
            },
                         serializedHubMessage[0].Serialized.ToArray());
        }
        public void SerializeMessages(string testName)
        {
            var testData = _invocationTestData[testName];

            var resolver = CreateHubProtocolResolver(new List <IHubProtocol> {
                new MessagePackHubProtocol(), new JsonHubProtocol()
            });
            var protocolNames        = testData.SupportedHubProtocols.ConvertAll(p => p.Name);
            var serializer           = new DefaultHubMessageSerializer(resolver, protocolNames, hubSupportedProtocols: null);
            var serializedHubMessage = serializer.SerializeMessage(_testMessage);

            var allBytes = new List <byte>();

            Assert.Equal(testData.SerializedCount, serializedHubMessage.Count);
            foreach (var message in serializedHubMessage)
            {
                allBytes.AddRange(message.Serialized.ToArray());
            }

            Assert.Equal(testData.Encoded, allBytes);
        }
Beispiel #3
0
 public RedisProtocol(DefaultHubMessageSerializer messageSerializer)
 {
     _messageSerializer = messageSerializer;
 }