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 InnovationsControllerTests
|
||||
{
|
||||
private static InnovationsController CreateController(IInnovationService service)
|
||||
{
|
||||
var controller = new InnovationsController(service, new StubMatchmakingService());
|
||||
var controller = new InnovationsController(
|
||||
service,
|
||||
new StubMatchmakingService(),
|
||||
new StubTestFeedbackService());
|
||||
var identity = new ClaimsIdentity(
|
||||
[new Claim("sub", "user:tester"), new Claim("role", "admin")],
|
||||
authenticationType: "test");
|
||||
@@ -55,37 +59,4 @@ public class InnovationsControllerTests
|
||||
|
||||
Assert.IsType<CreatedAtActionResult>(result.Result);
|
||||
}
|
||||
|
||||
private sealed class StubInnovationService : IInnovationService
|
||||
{
|
||||
public Task<IReadOnlyList<InnovationResponse>> ListAsync(
|
||||
string? challengeId,
|
||||
string? stage,
|
||||
string? query,
|
||||
bool onlyPublished,
|
||||
CancellationToken cancellationToken) => Task.FromResult<IReadOnlyList<InnovationResponse>>([]);
|
||||
|
||||
public Task<InnovationResponse?> GetAsync(string innovationId, CancellationToken cancellationToken) =>
|
||||
Task.FromResult<InnovationResponse?>(null);
|
||||
|
||||
public Task<InnovationResponse> CreateAsync(
|
||||
InnovationRequest request,
|
||||
CancellationToken cancellationToken) => Task.FromResult(new InnovationResponse(
|
||||
"innovation:new",
|
||||
request.Title,
|
||||
request.Summary ?? string.Empty,
|
||||
request.Description ?? string.Empty,
|
||||
request.ChallengeId,
|
||||
request.Stage,
|
||||
request.Cost,
|
||||
request.Contact,
|
||||
request.Media ?? [],
|
||||
request.Published,
|
||||
DateTimeOffset.UtcNow));
|
||||
|
||||
public Task<InnovationResponse?> UpdateAsync(
|
||||
string innovationId,
|
||||
InnovationRequest request,
|
||||
CancellationToken cancellationToken) => Task.FromResult<InnovationResponse?>(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user