public async void ServiceLifetimeManagerIgnoreBlazorHubProtocolTest(string functionName, Type type)
        {
            var protocolResolver = new DefaultHubProtocolResolver(new IHubProtocol[]
            {
                new JsonHubProtocol(),
                new MessagePackHubProtocol(),
                new CustomHubProtocol(),
            },
                                                                  NullLogger <DefaultHubProtocolResolver> .Instance);
            IOptions <HubOptions> globalHubOptions = Options.Create(new HubOptions()
            {
                SupportedProtocols = new List <string>()
                {
                    "json", "messagepack", MockProtocol, "json"
                }
            });
            IOptions <HubOptions <TestHub> > localHubOptions = Options.Create(new HubOptions <TestHub>()
            {
                SupportedProtocols = new List <string>()
                {
                    "json", "messagepack", MockProtocol
                }
            });
            var serviceConnectionManager = new TestServiceConnectionManager <TestHub>();
            var serviceLifetimeManager   = new ServiceLifetimeManager <TestHub>(serviceConnectionManager,
                                                                                new ClientConnectionManager(), protocolResolver, Logger, Marker, globalHubOptions, localHubOptions);

            await InvokeMethod(serviceLifetimeManager, functionName);

            Assert.Equal(1, serviceConnectionManager.GetCallCount(type));
            VerifyServiceMessage(functionName, serviceConnectionManager.ServiceMessage);
            Assert.Equal(2, (serviceConnectionManager.ServiceMessage as MulticastDataMessage).Payloads.Count);
        }
Exemplo n.º 2
0
        public async void ServiceLifetimeManagerTest(string functionName, Type type)
        {
            var serviceConnectionManager = new TestServiceConnectionManager <TestHub>();
            var serviceLifetimeManager   = new ServiceLifetimeManager <TestHub>(serviceConnectionManager,
                                                                                new ClientConnectionManager(), HubProtocolResolver, Logger, Marker);

            await InvokeMethod(serviceLifetimeManager, functionName);

            Assert.Equal(1, serviceConnectionManager.GetCallCount(type));
            VerifyServiceMessage(functionName, serviceConnectionManager.ServiceMessage);
        }
        public async void ServiceLifetimeManagerOnlyBlazorHubProtocolTest(string functionName, Type type)
        {
            var serviceConnectionManager = new TestServiceConnectionManager <TestHub>();
            var serviceLifetimeManager   = MockLifetimeManager(serviceConnectionManager);

            await InvokeMethod(serviceLifetimeManager, functionName);

            Assert.Equal(1, serviceConnectionManager.GetCallCount(type));
            VerifyServiceMessage(functionName, serviceConnectionManager.ServiceMessage);
            Assert.Equal(1, (serviceConnectionManager.ServiceMessage as MulticastDataMessage).Payloads.Count);
        }
        public async void ServiceLifetimeManagerTest(string functionName, Type type)
        {
            var serviceConnectionManager = new TestServiceConnectionManager <TestHub>();
            var serviceLifetimeManager   = new ServiceLifetimeManager <TestHub>(serviceConnectionManager,
                                                                                new ClientConnectionManager(), HubProtocolResolver, Logger, Marker, _globalHubOptions, _localHubOptions);

            await InvokeMethod(serviceLifetimeManager, functionName);

            Assert.Equal(1, serviceConnectionManager.GetCallCount(type));
            VerifyServiceMessage(functionName, serviceConnectionManager.ServiceMessage);
            Assert.Equal(2, (serviceConnectionManager.ServiceMessage as MulticastDataMessage).Payloads.Count);
        }
        public async void ServiceLifetimeManagerGroupTest(string functionName, Type type)
        {
            var serviceConnectionManager = new TestServiceConnectionManager <TestHub>();
            var blazorDetector           = new DefaultBlazorDetector();
            var serviceLifetimeManager   = new ServiceLifetimeManager <TestHub>(
                serviceConnectionManager,
                new ClientConnectionManager(),
                HubProtocolResolver,
                Logger,
                Marker,
                _globalHubOptions,
                _localHubOptions,
                blazorDetector);

            await InvokeMethod(serviceLifetimeManager, functionName);

            Assert.Equal(1, serviceConnectionManager.GetCallCount(type));
            VerifyServiceMessage(functionName, serviceConnectionManager.ServiceMessage);
            Assert.False(blazorDetector.IsBlazor(nameof(TestHub)));
        }