Files
predavanja/Events-MVC/Tests/Events.Tests.IntegrationTests/PeopleGuardShould.cs
2026-04-26 01:01:37 +02:00

24 lines
718 B
C#

using System.Net;
using Events.Tests.IntegrationTests.Infrastructure;
using Microsoft.AspNetCore.Mvc.Testing;
namespace Events.Tests.IntegrationTests;
public class PeopleGuardShould
{
[Fact]
public async Task RedirectToCountriesWhenPeoplePageIsRequestedWithoutCountries()
{
await using var factory = new CustomWebApplicationFactory();
using var client = factory.CreateClient(new WebApplicationFactoryClientOptions
{
AllowAutoRedirect = false
});
var response = await client.GetAsync("/People");
Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
Assert.Equal("/Countries", response.Headers.Location?.OriginalString);
}
}