Ejemplo n.º 1
0
        public void SetThreadCountUsingProcessorCount()
        {
            // Ideally we'd mock Environment.ProcessorCount to test edge cases.
            var expected = Clamp(Environment.ProcessorCount >> 1, 1, 16);

            var configuration = new ConfigurationBuilder().Build();

            var information = new KestrelServerInformation(configuration);

            Assert.Equal(expected, information.ThreadCount);
        }
Ejemplo n.º 2
0
        public void SetReuseStreamsUsingConfiguration(string input, bool expected)
        {
            var values = new Dictionary <string, string>
            {
                { "kestrel.reuseStreams", input }
            };

            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(values)
                                .Build();

            var information = new KestrelServerInformation(configuration);

            Assert.Equal(expected, information.ReuseStreams);
        }
Ejemplo n.º 3
0
        public void SetNoDelayUsingConfiguration()
        {
            var values = new Dictionary <string, string>
            {
                { "kestrel.noDelay", "false" }
            };

            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(values)
                                .Build();

            var information = new KestrelServerInformation(configuration);

            Assert.False(information.NoDelay);
        }
Ejemplo n.º 4
0
        public void StartWithEmptyAddressesThrows()
        {
            var server = CreateServer(configuration =>
            {
                var information = new KestrelServerInformation(configuration);

                information.Addresses.Clear();

                return(information);
            });

            var exception = Assert.Throws <InvalidOperationException>(() => StartDummyApplication(server));

            Assert.Equal("No recognized listening addresses were configured.", exception.Message);
        }
Ejemplo n.º 5
0
        public void SetThreadCountUsingConfiguration()
        {
            const int expected = 42;

            var values = new Dictionary <string, string>
            {
                { "kestrel.threadCount", expected.ToString() }
            };

            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(values)
                                .Build();

            var information = new KestrelServerInformation(configuration);

            Assert.Equal(expected, information.ThreadCount);
        }
Ejemplo n.º 6
0
        public void SetAddressesUsingConfiguration()
        {
            var expected = new List <string> {
                "http://localhost:1337", "https://localhost:42"
            };

            var values = new Dictionary <string, string>
            {
                { "server.urls", string.Join(";", expected) }
            };

            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(values)
                                .Build();

            var information = new KestrelServerInformation(configuration);

            Assert.Equal(expected, information.Addresses);
        }