48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using FastEndpoints;
|
|
using Microsoft.AspNetCore.Http;
|
|
using MissionControl.Domain.Entities;
|
|
using MissionControl.Server.Endpoints.Missions.MissionLaunches;
|
|
using Shouldly;
|
|
|
|
namespace MissionControl.Server.Tests.Endpoints.Missions.MissionLaunches;
|
|
|
|
public class CreateMissionLaunchTests
|
|
{
|
|
[Fact]
|
|
public async Task Returns_not_found_when_requested_mission_does_not_exist()
|
|
{
|
|
using var database = new TestDatabase();
|
|
var endpoint = Factory.Create<CreateMissionLaunch>(database.Context);
|
|
var request = new CreateMissionLaunchRequest
|
|
{
|
|
MissionId = Guid.NewGuid(),
|
|
ScheduledFor = DateTimeOffset.UtcNow,
|
|
Status = MissionLaunchStatus.Pending,
|
|
};
|
|
|
|
await endpoint.HandleAsync(request, CancellationToken.None);
|
|
|
|
endpoint.HttpContext.Response.StatusCode.ShouldBe(StatusCodes.Status404NotFound);
|
|
}
|
|
|
|
[Fact]
|
|
public void Rejects_empty_mission_id_guid()
|
|
{
|
|
var validator = new CreateMissionLaunchRequestValidator();
|
|
|
|
var result = validator.Validate(
|
|
new CreateMissionLaunchRequest
|
|
{
|
|
MissionId = Guid.Empty,
|
|
ScheduledFor = default,
|
|
Status = MissionLaunchStatus.Pending,
|
|
}
|
|
);
|
|
|
|
result.IsValid.ShouldBeFalse();
|
|
result.Errors.ShouldContain(e =>
|
|
e.PropertyName == nameof(CreateMissionLaunchRequest.MissionId)
|
|
);
|
|
}
|
|
}
|