Files
Ho Ngoc Hai 76d75c753b Migrate
2026-05-23 18:37:02 +07:00

45 lines
1.2 KiB
C#

using System.Net;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Testing;
using Xunit;
namespace AdsTrackingService.FunctionalTests.Controllers;
/// <summary>
/// EN: Functional tests for tracking pixel and health endpoints.
/// VI: Functional tests cho endpoint tracking pixel và health.
/// </summary>
public class PixelsControllerTests : IClassFixture<CustomWebApplicationFactory>
{
private readonly HttpClient _client;
public PixelsControllerTests(CustomWebApplicationFactory factory)
{
_client = factory.CreateClient(new WebApplicationFactoryClientOptions
{
AllowAutoRedirect = false,
});
}
[Fact]
public async Task GetPixelCode_WithUnknownAdvertiser_ShouldReturnNotFound()
{
// Act
var response = await _client.GetAsync(
$"/api/v1/ads-tracking/pixels/{Guid.NewGuid()}");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
}
[Fact]
public async Task HealthCheck_ShouldReturnHealthy()
{
// Act
var response = await _client.GetAsync("/health/live");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
}
}