public void DefaultHubProtocolResolverTestsCanCreateSupportedProtocols(IHubProtocol protocol)
        {
            var mockConnection = new Mock <HubConnectionContext>(Channel.CreateUnbounded <HubMessage>().Out, new Mock <ConnectionContext>().Object);

            Assert.IsType(
                protocol.GetType(),
                new DefaultHubProtocolResolver(Options.Create(new HubOptions())).GetProtocol(protocol.Name, mockConnection.Object));
        }
Esempio n. 2
0
        public void DefaultHubProtocolResolverTestsCanCreateAllProtocols(IHubProtocol protocol)
        {
            var resolver = new DefaultHubProtocolResolver(AllProtocols, NullLogger <DefaultHubProtocolResolver> .Instance);

            Assert.IsType(
                protocol.GetType(),
                resolver.GetProtocol(protocol.Name, AllProtocolNames));
        }
        public void DefaultHubProtocolResolverTestsCanCreateSupportedProtocols(IHubProtocol protocol)
        {
            var mockConnection = new Mock <HubConnectionContext>(new Mock <ConnectionContext>().Object, TimeSpan.FromSeconds(30), NullLoggerFactory.Instance);

            Assert.IsType(
                protocol.GetType(),
                new DefaultHubProtocolResolver(Options.Create(new HubOptions())).GetProtocol(protocol.Name, mockConnection.Object));
        }
Esempio n. 4
0
        public void DefaultHubProtocolResolverCreatesProtocolswhenSupoortedProtocolsIsNull(IHubProtocol protocol)
        {
            List <string> supportedProtocols = null;
            var           resolver           = new DefaultHubProtocolResolver(AllProtocols, NullLogger <DefaultHubProtocolResolver> .Instance);

            Assert.IsType(
                protocol.GetType(),
                resolver.GetProtocol(protocol.Name, supportedProtocols));
        }
Esempio n. 5
0
        public void DefaultHubProtocolResolverTestsCanCreateSupportedProtocols(IHubProtocol protocol)
        {
            var supportedProtocols = new List <string> {
                protocol.Name
            };
            var resolver = new DefaultHubProtocolResolver(AllProtocols, NullLogger <DefaultHubProtocolResolver> .Instance);

            Assert.IsType(
                protocol.GetType(),
                resolver.GetProtocol(protocol.Name, supportedProtocols));
        }
Esempio n. 6
0
        private static bool TryGetPayload(IHubProtocol protocol, InvocationMessage invocationMessage, out ReadOnlySequence <byte> payload)
        {
            var buffer = new ReadOnlySequence <byte>(protocol.GetMessageBytes(invocationMessage));

            if (protocol is JsonHubProtocol)
            {
                return(TextMessageParser.TryParseMessage(ref buffer, out payload));
            }
            else if (protocol is MessagePackHubProtocol)
            {
                return(BinaryMessageParser.TryParseMessage(ref buffer, out payload));
            }

            throw new ArgumentException($"{protocol.GetType()} is not supported");
        }
        public void DefaultHubProtocolResolverTestsCanCreateSupportedProtocols(IHubProtocol protocol)
        {
            var connection = new Mock <ConnectionContext>();

            connection.Setup(m => m.Features).Returns(new FeatureCollection());
            var mockConnection = new Mock <HubConnectionContext>(connection.Object, TimeSpan.FromSeconds(30), NullLoggerFactory.Instance)
            {
                CallBase = true
            };
            var resolver = new DefaultHubProtocolResolver(Options.Create(new HubOptions()), AllProtocols, NullLogger <DefaultHubProtocolResolver> .Instance);

            Assert.IsType(
                protocol.GetType(),
                resolver.GetProtocol(protocol.Name, mockConnection.Object));
        }
        public void DefaultHubProtocolResolverCreatesProtocolswhenSupoortedProtocolsIsNull(IHubProtocol protocol)
        {
            var connection = new Mock <ConnectionContext>();

            connection.Setup(m => m.Features).Returns(new FeatureCollection());
            var mockConnection = new Mock <HubConnectionContext>(connection.Object, TimeSpan.FromSeconds(30), NullLoggerFactory.Instance)
            {
                CallBase = true
            };
            List <string> supportedProtocols = null;
            var           resolver           = new DefaultHubProtocolResolver(AllProtocols, NullLogger <DefaultHubProtocolResolver> .Instance);

            Assert.IsType(
                protocol.GetType(),
                resolver.GetProtocol(protocol.Name, supportedProtocols, mockConnection.Object));
        }