using System.Net; using FluentAssertions; using Moq; using Oms.Application.Dtos.System; using Oms.Domain.SystemAggregate.Entities; using Oms.Domain.SystemAggregate.Repositories; using SimpleAdmin.Api.IntegrationTests.Support; namespace SimpleAdmin.Api.IntegrationTests; public class CountryApiIntegrationTests { [Fact] public async Task GetCountryList_ShouldReturnOrderedItemsFromRepository() { var repository = new Mock(); repository .Setup(x => x.GetListAsync( It.IsAny>>(), It.IsAny?>(), It.IsAny())) .ReturnsAsync([ new Country { Id = 2, CountryCode = "US", EnglishName = "United States", ChineseName = "美国" }, new Country { Id = 1, CountryCode = "AU", EnglishName = "Australia", ChineseName = "澳大利亚" }, new Country { Id = 3, CountryCode = "US", EnglishName = "America", ChineseName = "美利坚" } ]); await using var host = await SimpleAdminApiTestHost.CreateAsync(repository.Object); var response = await host.Client.GetAsync("/system/country/list"); response.StatusCode.Should().Be(HttpStatusCode.OK, string.Join(" | ", host.RoutePatterns)); var items = await response.Content.ReadFromJsonAsync>(); items.Should().NotBeNull(); items!.Select(x => x.CountryCode).Should().ContainInOrder("AU", "US", "US"); items.Select(x => x.EnglishName).Should().ContainInOrder("Australia", "America", "United States"); } }