test(backend): cover step 17 modules and extract stubs
Add tests for partnership workflow, middleman adaptation and idea notifications; extract reusable test stubs into separate files; add architecture guard forbidding object-valued dictionaries in data contracts.
This commit is contained in:
@@ -5,6 +5,7 @@ using TarninaHub.Application.Abstractions;
|
||||
using TarninaHub.Application.Dtos;
|
||||
using TarninaHub.Controllers;
|
||||
using TarninaHub.Tests.Matchmaking;
|
||||
using TarninaHub.Tests.Stubs;
|
||||
|
||||
namespace TarninaHub.Tests.Controllers;
|
||||
|
||||
@@ -12,7 +13,10 @@ public class SubmissionsControllerTests
|
||||
{
|
||||
private static SubmissionsController CreateController(ISubmissionService service, string role = "operator")
|
||||
{
|
||||
var controller = new SubmissionsController(service, new StubMatchmakingService());
|
||||
var controller = new SubmissionsController(
|
||||
service,
|
||||
new StubMatchmakingService(),
|
||||
new StubNotificationService());
|
||||
var identity = new ClaimsIdentity(
|
||||
[new Claim("sub", "user:tester"), new Claim("role", role)],
|
||||
authenticationType: "test");
|
||||
@@ -81,40 +85,4 @@ public class SubmissionsControllerTests
|
||||
|
||||
Assert.IsType<NotFoundResult>(result.Result);
|
||||
}
|
||||
|
||||
private sealed class StubSubmissionService : ISubmissionService
|
||||
{
|
||||
public SubmissionResponse? Current { get; set; }
|
||||
|
||||
public SubmissionResponse? UpdateResult { get; set; }
|
||||
|
||||
public string? LastRequestedStatus { get; private set; }
|
||||
|
||||
public Task<SubmissionResponse> CreateAsync(
|
||||
string authorId,
|
||||
CreateSubmissionRequest request,
|
||||
CancellationToken cancellationToken) => Task.FromResult(SampleSubmission("new"));
|
||||
|
||||
public Task<PagedResponse<SubmissionResponse>> ListAsync(
|
||||
string viewerId,
|
||||
bool isStaff,
|
||||
string? status,
|
||||
int page,
|
||||
int pageSize,
|
||||
CancellationToken cancellationToken) => Task.FromResult(
|
||||
new PagedResponse<SubmissionResponse>([], page, pageSize, 0));
|
||||
|
||||
public Task<SubmissionResponse?> GetAsync(string submissionId, CancellationToken cancellationToken) =>
|
||||
Task.FromResult(Current);
|
||||
|
||||
public Task<SubmissionResponse?> UpdateStatusAsync(
|
||||
string submissionId,
|
||||
string newStatus,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
LastRequestedStatus = newStatus;
|
||||
|
||||
return Task.FromResult(UpdateResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user