using System.Net; using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Testing; using Xunit; namespace Yavsc.Org.Tests.Controllers; public class CommandFormsControllerTests : IClassFixture { private readonly TestWebApplicationFactory _factory; public CommandFormsControllerTests(TestWebApplicationFactory factory) { _factory = factory; } private HttpClient CreateAdminClient() { var http = _factory.CreateClient(new WebApplicationFactoryClientOptions { HandleCookies = true, }); http.DefaultRequestHeaders.Add(TestAuthPolicyProvider.HeaderName, TestAuthPolicyProvider.AdminRole); return http; } [Fact] public async Task Create_GET_returns_200_for_admin() { var http = CreateAdminClient(); var response = await http.GetAsync("/CommandForms/Create", TestContext.Current.CancellationToken); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var body = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken); Assert.Contains("Create", body); } }