Skip to content

Commit 9156ebd

Browse files
committed
fix: Fixed failing unit test due to unsupported operation in latest .NET patches
1 parent 8a87caf commit 9156ebd

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

Tools/LambdaTestTool/tests/LambdaFunctions/AspNetCoreAPIExample/LocalEntryPoint.cs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using System.Threading.Tasks;
44
using Microsoft.AspNetCore.Builder;
55
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.AspNetCore.Http;
7+
using Microsoft.Extensions.DependencyInjection;
68
using Microsoft.Extensions.Hosting;
79

810
namespace AspNetCoreAPIExample
@@ -14,14 +16,39 @@ public class LocalEntryPoint
1416
{
1517
public static void Main(string[] args)
1618
{
17-
CreateHostBuilder(args).Build().Run();
19+
CreateHostBuilder(args).Run();
1820
}
1921

20-
public static WebApplicationBuilder CreateHostBuilder(string[] args)
22+
public static WebApplication CreateHostBuilder(string[] args)
2123
{
2224
var builder = WebApplication.CreateBuilder(args);
23-
builder.WebHost.UseStartup<Startup>();
24-
return builder;
25+
26+
builder.Services.AddScoped<IFakeDependency, FakeDependency>();
27+
builder.Services.AddControllers();
28+
29+
var app = builder.Build();
30+
31+
if (app.Environment.IsDevelopment())
32+
{
33+
app.UseDeveloperExceptionPage();
34+
}
35+
36+
app.UseHttpsRedirection();
37+
38+
app.UseRouting();
39+
40+
app.UseAuthorization();
41+
42+
app.UseEndpoints(endpoints =>
43+
{
44+
endpoints.MapControllers();
45+
endpoints.MapGet("/", async context =>
46+
{
47+
await context.Response.WriteAsync("Welcome to running ASP.NET Core on AWS Lambda");
48+
});
49+
});
50+
51+
return app;
2552
}
2653
}
2754
}

0 commit comments

Comments
 (0)