Refactor project files for improved readability and structure
CI / Backend (build + test) (push) Successful in 1m18s
CI / Frontend (lint + typecheck + build) (push) Successful in 31s

- Cleaned up whitespace in Directory.Build.props and Directory.Packages.props for consistency.
- Reformatted project file references in PnvPanel.Api.csproj for better clarity.
- Enhanced code readability in various endpoint files by adjusting line breaks and indentation.
- Standardized method signatures and improved formatting in ResultExtensions and multiple endpoint classes for better maintainability.
This commit is contained in:
Leonid Pershin
2026-07-14 07:24:13 +03:00
parent 9d5424bb9c
commit df137ca5a7
285 changed files with 6911 additions and 2063 deletions
@@ -16,8 +16,17 @@ public class AddTicketCommentCommandHandlerTests
private readonly IRealtimeNotifier _notifier = Substitute.For<IRealtimeNotifier>();
private static CurrentUserProfile Profile(Guid userId, string role) =>
new(userId, "user", Guid.NewGuid(), role, IsActivated: true, IsBlocked: false, MaxConfigs: 3,
MaxIpLimit: RoleQuota.Unlimited, SubscriptionToken: "token");
new(
userId,
"user",
Guid.NewGuid(),
role,
IsActivated: true,
IsBlocked: false,
MaxConfigs: 3,
MaxIpLimit: RoleQuota.Unlimited,
SubscriptionToken: "token"
);
[Fact]
public async Task Handle_WhenOwnerComments_AddsCommentAndDoesNotNotifySelf()
@@ -28,16 +37,33 @@ public class AddTicketCommentCommandHandlerTests
dbContext.SupportTickets.Add(ticket);
await dbContext.SaveChangesAsync(CancellationToken.None);
_identityService.GetProfileAsync(userId, Arg.Any<CancellationToken>()).Returns(Profile(userId, "user"));
_identityService
.GetProfileAsync(userId, Arg.Any<CancellationToken>())
.Returns(Profile(userId, "user"));
var currentUser = FakeCurrentUser.Authenticated(userId, "alice");
var handler = new AddTicketCommentCommandHandler(dbContext, _identityService, _fileStorage, _notifier, currentUser);
var handler = new AddTicketCommentCommandHandler(
dbContext,
_identityService,
_fileStorage,
_notifier,
currentUser
);
var result = await handler.Handle(new AddTicketCommentCommand(ticket.Id, "апдейт", []), CancellationToken.None);
var result = await handler.Handle(
new AddTicketCommentCommand(ticket.Id, "апдейт", []),
CancellationToken.None
);
Assert.True(result.IsSuccess);
Assert.Equal("апдейт", result.Value.Body);
await _notifier.DidNotReceive().NotifyTicketUpdatedAsync(Arg.Any<Guid>(), Arg.Any<Guid>(), Arg.Any<CancellationToken>());
await _notifier
.DidNotReceive()
.NotifyTicketUpdatedAsync(
Arg.Any<Guid>(),
Arg.Any<Guid>(),
Arg.Any<CancellationToken>()
);
}
[Fact]
@@ -50,15 +76,28 @@ public class AddTicketCommentCommandHandlerTests
dbContext.SupportTickets.Add(ticket);
await dbContext.SaveChangesAsync(CancellationToken.None);
_identityService.GetProfileAsync(adminId, Arg.Any<CancellationToken>()).Returns(Profile(adminId, "admin"));
_identityService
.GetProfileAsync(adminId, Arg.Any<CancellationToken>())
.Returns(Profile(adminId, "admin"));
var currentUser = FakeCurrentUser.Authenticated(adminId, "admin");
var handler = new AddTicketCommentCommandHandler(dbContext, _identityService, _fileStorage, _notifier, currentUser);
var handler = new AddTicketCommentCommandHandler(
dbContext,
_identityService,
_fileStorage,
_notifier,
currentUser
);
var result = await handler.Handle(new AddTicketCommentCommand(ticket.Id, "ответ админа", []), CancellationToken.None);
var result = await handler.Handle(
new AddTicketCommentCommand(ticket.Id, "ответ админа", []),
CancellationToken.None
);
Assert.True(result.IsSuccess);
await _notifier.Received(1).NotifyTicketUpdatedAsync(ticket.Id, ownerId, Arg.Any<CancellationToken>());
await _notifier
.Received(1)
.NotifyTicketUpdatedAsync(ticket.Id, ownerId, Arg.Any<CancellationToken>());
}
[Fact]
@@ -71,12 +110,23 @@ public class AddTicketCommentCommandHandlerTests
dbContext.SupportTickets.Add(ticket);
await dbContext.SaveChangesAsync(CancellationToken.None);
_identityService.GetProfileAsync(strangerId, Arg.Any<CancellationToken>()).Returns(Profile(strangerId, "user"));
_identityService
.GetProfileAsync(strangerId, Arg.Any<CancellationToken>())
.Returns(Profile(strangerId, "user"));
var currentUser = FakeCurrentUser.Authenticated(strangerId);
var handler = new AddTicketCommentCommandHandler(dbContext, _identityService, _fileStorage, _notifier, currentUser);
var handler = new AddTicketCommentCommandHandler(
dbContext,
_identityService,
_fileStorage,
_notifier,
currentUser
);
var result = await handler.Handle(new AddTicketCommentCommand(ticket.Id, "текст", []), CancellationToken.None);
var result = await handler.Handle(
new AddTicketCommentCommand(ticket.Id, "текст", []),
CancellationToken.None
);
Assert.False(result.IsSuccess);
Assert.Equal(SupportErrors.NotFound, result.Error);
@@ -92,12 +142,23 @@ public class AddTicketCommentCommandHandlerTests
dbContext.SupportTickets.Add(ticket);
await dbContext.SaveChangesAsync(CancellationToken.None);
_identityService.GetProfileAsync(userId, Arg.Any<CancellationToken>()).Returns(Profile(userId, "user"));
_identityService
.GetProfileAsync(userId, Arg.Any<CancellationToken>())
.Returns(Profile(userId, "user"));
var currentUser = FakeCurrentUser.Authenticated(userId);
var handler = new AddTicketCommentCommandHandler(dbContext, _identityService, _fileStorage, _notifier, currentUser);
var handler = new AddTicketCommentCommandHandler(
dbContext,
_identityService,
_fileStorage,
_notifier,
currentUser
);
var result = await handler.Handle(new AddTicketCommentCommand(ticket.Id, "текст", []), CancellationToken.None);
var result = await handler.Handle(
new AddTicketCommentCommand(ticket.Id, "текст", []),
CancellationToken.None
);
Assert.False(result.IsSuccess);
Assert.Equal(SupportErrors.TicketClosed, result.Error);