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); }
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); }
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); }
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); }
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); }
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); }