Exemplo n.º 1
0
        public void INodeJSServiceFactory_CreatesAHttpNodeJSServiceIfConcurrencyIsNoneOrOnly1ProcessIsRequested(Concurrency dummyConcurrency,
                                                                                                                int dummyNumLogicalProcessors,
                                                                                                                int dummyConcurrencyDegree)
        {
            // Arrange
            var services = new ServiceCollection();

            services.AddNodeJS();
            services.AddSingleton(typeof(IEnvironmentService), new DummyEnvironmentService(dummyNumLogicalProcessors));
            services.Configure <OutOfProcessNodeJSServiceOptions>(options =>
            {
                options.Concurrency       = dummyConcurrency;
                options.ConcurrencyDegree = dummyConcurrencyDegree;
            });
            IServiceProvider serviceProvider = services.BuildServiceProvider();

            // Act
            var result = NodeJSServiceCollectionExtensions.INodeJSServiceFactory(serviceProvider) as HttpNodeJSService;

            // Assert
            Assert.NotNull(result);
        }
Exemplo n.º 2
0
        public void INodeJSServiceFactory_CreatesAHttpNodeJSPoolServiceIfConcurrencyIsMultiProcessAndMoreThan1ProcessesIsRequested(int dummyConcurrencyDegree,
                                                                                                                                   int dummyNumLogicalProcessors,
                                                                                                                                   int expectedSize)
        {
            // Arrange
            var services = new ServiceCollection();

            services.AddNodeJS();
            services.AddSingleton(typeof(IEnvironmentService), new DummyEnvironmentService(dummyNumLogicalProcessors));
            services.Configure <OutOfProcessNodeJSServiceOptions>(options =>
            {
                options.Concurrency       = Concurrency.MultiProcess;
                options.ConcurrencyDegree = dummyConcurrencyDegree;
            });
            IServiceProvider serviceProvider = services.BuildServiceProvider();

            // Act
            var result = NodeJSServiceCollectionExtensions.INodeJSServiceFactory(serviceProvider) as HttpNodeJSPoolService;

            // Assert
            Assert.NotNull(result);
            Assert.Equal(expectedSize, result.Size);
        }