'Integration tests api in .net6.0

SO when I did integration tests for api's, I used tio have a xunit project and used Microsoft.AspNetcore.Mvc.Testing.

There I used a WebApplicationFactory<namespace.Startup>().

According to microsoft docs they provide roughly the same:

 // Arrange
    _server = new TestServer(new WebHostBuilder()
       .UseStartup<Startup>());
    _client = _server.CreateClient();

found here: api integration tests

However since .net6.0 came out when creating an api project and other projects aswell, they don't seem to have a startup class anymore, all is embedded in the program.cs file, But program.cs file doesn't contain a class either, so i'm a little bit stuck on what to use in my webapplicationfactory<namesapce.startup> -> since there is no startup anymore

Any idea what to do here?

Edit: program.cs of my api (with controllers)

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();



public partial class Program { }

my tests:

public class ApiTests
    {
        
        private readonly HttpClient client;
        private readonly TestServer _server;

        private const string url = "https://localhost/api/network";

        public ApiTests()
        {
            _server = new TestServer(WebApplicationFactory<Network_Monitor_Agent.Program>);   
        }

        [Fact]
        public async Task GetRequest_Should_Return_Success_Information()
        {
            var response = await client.GetAsync(url);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

        }
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source