Răsfoiți Sursa

Check the environment on Helix (#41971)

Javier Calvarro Nelson 3 ani în urmă
părinte
comite
1ef0d8b513

+ 19 - 1
src/Mvc/test/Mvc.FunctionalTests/SimpleWithWebApplicationBuilderTests.cs

@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc.Testing;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Hosting;
+using Xunit.Abstractions;
 
 namespace Microsoft.AspNetCore.Mvc.FunctionalTests;
 
@@ -14,13 +15,15 @@ public class SimpleWithWebApplicationBuilderTests : IClassFixture<MvcTestFixture
 {
     private readonly MvcTestFixture<SimpleWebSiteWithWebApplicationBuilder.Program> _fixture;
 
-    public SimpleWithWebApplicationBuilderTests(MvcTestFixture<SimpleWebSiteWithWebApplicationBuilder.Program> fixture)
+    public SimpleWithWebApplicationBuilderTests(MvcTestFixture<SimpleWebSiteWithWebApplicationBuilder.Program> fixture, ITestOutputHelper helper)
     {
         _fixture = fixture;
+        Helper = helper;
         Client = _fixture.CreateDefaultClient();
     }
 
     public HttpClient Client { get; }
+    public ITestOutputHelper Helper { get; }
 
     [Fact]
     public async Task HelloWorld()
@@ -141,6 +144,21 @@ public class SimpleWithWebApplicationBuilderTests : IClassFixture<MvcTestFixture
         Assert.Equal(expected, content);
     }
 
+    [Fact]
+    public async Task Get_ConfigDebugView()
+    {
+        // Arrange
+        using var client = new WebApplicationFactory<SimpleWebSiteWithWebApplicationBuilder.Program>().CreateClient();
+
+        // Act
+        var content = await client.GetStringAsync("http://localhost/config");
+
+        Helper.WriteLine(content);
+
+        // Assert
+        Assert.NotEmpty(content);
+    }
+
     [Fact]
     public async Task Configuration_Can_Be_Overridden()
     {

+ 4 - 0
src/Mvc/test/WebSites/SimpleWebSiteWithWebApplicationBuilder/Program.cs

@@ -36,6 +36,10 @@ app.MapGet("/many-results", (int id) =>
 
 app.MapGet("/problem", () => Results.Problem("Some problem"));
 
+app.MapGet("/config", (IConfiguration config, HttpContext context) => {    
+    return context.Response.WriteAsync(((IConfigurationRoot)config).GetDebugView());
+});
+
 app.MapGet("/environment", (IHostEnvironment environment) => environment.EnvironmentName);
 app.MapGet("/webroot", (IWebHostEnvironment environment) => environment.WebRootPath);