39 lines
1.7 KiB
C#
39 lines
1.7 KiB
C#
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<ICountryRepository>();
|
|
repository
|
|
.Setup(x => x.GetListAsync(
|
|
It.IsAny<System.Linq.Expressions.Expression<Func<Country, bool>>>(),
|
|
It.IsAny<Dictionary<string, bool>?>(),
|
|
It.IsAny<CancellationToken>()))
|
|
.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<List<CountryOutput>>();
|
|
items.Should().NotBeNull();
|
|
items!.Select(x => x.CountryCode).Should().ContainInOrder("AU", "US", "US");
|
|
items.Select(x => x.EnglishName).Should().ContainInOrder("Australia", "America", "United States");
|
|
}
|
|
}
|