54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using System.Net;
|
|
using FluentAssertions;
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
using Xunit;
|
|
|
|
namespace MissionService.FunctionalTests.Controllers;
|
|
|
|
/// <summary>
|
|
/// EN: Functional tests for mission endpoints.
|
|
/// VI: Functional tests cho các endpoint mission.
|
|
/// </summary>
|
|
public class MissionsControllerTests : IClassFixture<CustomWebApplicationFactory>
|
|
{
|
|
private readonly HttpClient _client;
|
|
|
|
public MissionsControllerTests(CustomWebApplicationFactory factory)
|
|
{
|
|
_client = factory.CreateClient(new WebApplicationFactoryClientOptions
|
|
{
|
|
AllowAutoRedirect = false,
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetByCategory_ShouldReturnOk()
|
|
{
|
|
// Act
|
|
var response = await _client.GetAsync("/api/v1/missions/category/daily");
|
|
|
|
// Assert
|
|
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetAvailableMissions_WithoutAuthentication_ShouldReturnUnauthorized()
|
|
{
|
|
// Act
|
|
var response = await _client.GetAsync("/api/v1/missions");
|
|
|
|
// Assert
|
|
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task HealthCheck_ShouldReturnHealthy()
|
|
{
|
|
// Act
|
|
var response = await _client.GetAsync("/health/live");
|
|
|
|
// Assert
|
|
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
}
|
|
}
|