using System.Security.Claims; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using TarninaHub.Application.Abstractions; using TarninaHub.Application.Dtos; using TarninaHub.Controllers; using TarninaHub.Tests.Matchmaking; using TarninaHub.Tests.Stubs; namespace TarninaHub.Tests.Controllers; public class InnovationsControllerTests { private static InnovationsController CreateController(IInnovationService service) { var controller = new InnovationsController( service, new StubMatchmakingService(), new StubTestFeedbackService()); var identity = new ClaimsIdentity( [new Claim("sub", "user:tester"), new Claim("role", "admin")], authenticationType: "test"); controller.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(identity) }, }; return controller; } private static InnovationRequest SampleRequest(string stage) => new( "Klub sąsiedzki", "Streszczenie", "Opis", "social_challenge:seniorzy", stage, null, null, null, true); [Fact] public async Task Create_RejectsUnknownStage() { var controller = CreateController(new StubInnovationService()); var result = await controller.Create(SampleRequest("draft"), CancellationToken.None); Assert.IsType(result.Result); } [Fact] public async Task Create_AcceptsKnownStage() { var controller = CreateController(new StubInnovationService()); var result = await controller.Create(SampleRequest("pilot"), CancellationToken.None); Assert.IsType(result.Result); } }