Refactored the GridPlanner class to optimize slot management during grid generation, ensuring more efficient handling of slots. Updated the GenerateGridDialog component to improve its layout and usability, enhancing the overall user experience when interacting with slot lists. These changes contribute to better functionality and accessibility in grid management.
61 lines
2.2 KiB
C#
61 lines
2.2 KiB
C#
using NSubstitute;
|
|
using TeleWave.Application.Admin.Users.ListUsers;
|
|
using TeleWave.Application.Common.Interfaces;
|
|
using TeleWave.Application.Common.Models;
|
|
using Xunit;
|
|
|
|
namespace TeleWave.Application.Tests.Admin;
|
|
|
|
/// <summary>
|
|
/// Список пользователей: хендлер только перекладывает параметры запроса в порт — Identity живёт
|
|
/// вне <c>IAppDbContext</c>. Проверяется именно перекладка: потерянный фильтр здесь означал бы
|
|
/// заблокированных вперемешку с активными.
|
|
/// </summary>
|
|
public class ListUsersTests
|
|
{
|
|
[Fact]
|
|
public async Task PassesEveryFilterToIdentityService()
|
|
{
|
|
var identity = Substitute.For<IIdentityService>();
|
|
var roleId = Guid.NewGuid();
|
|
var page = new PagedList<UserSummaryDto>([], 0, 2, 25);
|
|
identity
|
|
.ListUsersAsync(Arg.Any<UserListFilter>(), Arg.Any<CancellationToken>())
|
|
.Returns(page);
|
|
|
|
var result = await new ListUsersQueryHandler(identity).Handle(
|
|
new ListUsersQuery(2, 25, "иван", roleId, IsBlocked: true, Sort: "created", Desc: true),
|
|
CancellationToken.None
|
|
);
|
|
|
|
Assert.Same(page, result);
|
|
await identity
|
|
.Received(1)
|
|
.ListUsersAsync(
|
|
new UserListFilter(2, 25, "иван", roleId, true, "created", true),
|
|
Arg.Any<CancellationToken>()
|
|
);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task DefaultsSortAndDirection_WhenNotAsked()
|
|
{
|
|
var identity = Substitute.For<IIdentityService>();
|
|
identity
|
|
.ListUsersAsync(Arg.Any<UserListFilter>(), Arg.Any<CancellationToken>())
|
|
.Returns(new PagedList<UserSummaryDto>([], 0, 1, 20));
|
|
|
|
await new ListUsersQueryHandler(identity).Handle(
|
|
new ListUsersQuery(1, 20, null, null, null),
|
|
CancellationToken.None
|
|
);
|
|
|
|
await identity
|
|
.Received(1)
|
|
.ListUsersAsync(
|
|
Arg.Is<UserListFilter>(f => f.Sort == null && !f.Desc && f.Search == null),
|
|
Arg.Any<CancellationToken>()
|
|
);
|
|
}
|
|
}
|