예제 #1
0
        public async Task ServerRespondsOnMultipleConfiguredPort()
        {
            const string file     = FileNames.Ports.MultipleEndpoints;
            var          settings = new GlobalServerSettings {
                FileName = file
            };

            using var server = new TestRealServerImpl(settings);
            server.FileSystem.AddFile(file, FileLoader.GetFileContents(file));
            await server.Run();

            using var client = new HttpClient();

            var result1 = await client.GetAsync("http://localhost:5000/things/1234");

            var result2 = await client.GetAsync("http://localhost:5001/things/1234");

            var result3 = await client.GetAsync("https://localhost:5002/things/1234");

            var result4 = await client.GetAsync("https://localhost:5003/things/1234");

            await TestResult(result1);
            await TestResult(result2);
            await TestResult(result3);
            await TestResult(result4);
        }
예제 #2
0
        public async Task ServerRespondsOnConfiguredPort()
        {
            const string file     = FileNames.Ports.SslDisabled;
            var          settings = new GlobalServerSettings {
                FileName = file
            };

            using var server = new TestRealServerImpl(settings);
            server.FileSystem.AddFile(file, FileLoader.GetFileContents(file));
            await server.Run();

            using var client = new HttpClient();

            var result = await client.GetAsync("http://localhost:5000/things/1234");

            var resultString = await result.Content.ReadAsStringAsync();

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
            Assert.Equal("{\"Hello\":\"World\"}", resultString);
        }