Ejemplo n.º 1
0
        public async Task ShouldRequireMinimumFields()
        {
            var command = new CreateRaceStageCommand();

            var result = await SendAsync(command);

            result.IsBadRequest.Should().BeTrue();
            result.ValidationFailures.Should().ContainNotEmptyValidationErrorForProperty(nameof(CreateRaceStageCommand.RaceId));
            result.ValidationFailures.Should().ContainNotEmptyValidationErrorForProperty(nameof(CreateRaceStageCommand.StartLocation));
            result.ValidationFailures.Should().ContainNotEmptyValidationErrorForProperty(nameof(CreateRaceStageCommand.FinishLocation));
        }
Ejemplo n.º 2
0
        public async Task ShouldReturnBadRequestWhenRaceDoesNotExist()
        {
            var command = new CreateRaceStageCommand()
            {
                RaceId         = 123,
                StartLocation  = "Paris",
                FinishLocation = "Edinburgh",
            };

            var result = await SendAsync(command);

            result.IsNotFound.Should().BeTrue();
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <GetRaceStageByIdVm> > PostRaceStage(int raceId, CreateRaceStageCommand command)
        {
            if (command.RaceId != raceId)
            {
                return(BadRequest());
            }

            var result = await _mediator.Send(command);

            return(ResponseHelpers.BuildCreatedAtResponse(
                       this,
                       result,
                       nameof(GetRaceStage),
                       () => new { raceId, stageId = result.Content.Id }));
        }