Files
pos-system/services/membership-service-net/tests/MembershipService.FunctionalTests/Controllers/MembersControllerTests.cs
Ho Ngoc Hai 4a1a0ef79c feat(storage-service): Add Social Service to Docker Compose and enhance IAM service integration
- Introduced a new social-service in the Docker Compose configuration for local development, including build context, environment variables, and health checks.
- Updated architecture documentation to reflect the new storage service structure and its components, including user storage quotas and file management.
- Enhanced README files to provide clearer instructions on service setup, configuration, and API endpoints for file storage management.
- Implemented caching mechanisms in the IAM service client for improved performance and reduced latency in user information retrieval.
- Updated appsettings for development to include caching settings for IAM service interactions.
2026-01-13 00:28:41 +07:00

60 lines
1.6 KiB
C#

using System.Net;
using System.Net.Http.Json;
using FluentAssertions;
using MembershipService.API.Application.Commands;
using MembershipService.API.Application.Queries;
using Xunit;
namespace MembershipService.FunctionalTests.Controllers;
/// <summary>
/// EN: Functional tests for MembersController.
/// VI: Functional tests cho MembersController.
/// </summary>
public class MembersControllerTests : IClassFixture<CustomWebApplicationFactory>
{
private readonly HttpClient _client;
public MembersControllerTests(CustomWebApplicationFactory factory)
{
_client = factory.CreateClient();
}
[Fact]
public async Task GetMembers_ShouldReturnEmptyList()
{
// Act
var response = await _client.GetAsync("/api/v1/members?page=1&pageSize=10");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
}
[Fact]
public async Task GetMemberById_WithInvalidId_ShouldReturnUnauthorized()
{
// Act
var response = await _client.GetAsync($"/api/v1/members/{Guid.NewGuid()}");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
}
[Fact]
public async Task CreateMember_WithoutAuth_ShouldReturnUnauthorized()
{
// Arrange
var command = new CreateMemberCommand
{
UserId = Guid.NewGuid(),
CountryCode = "VN"
};
// Act
var response = await _client.PostAsJsonAsync("/api/v1/members", command);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
}
}