public async Task UpdateVermittlerCommandAsAnonymous_ShouldReturnUnauthorizedAccessException() { await CreateVermittlerAsync(); UpdateVermittlerCommand command = await CreateUpdateVermittlerCommandAsync(); FluentActions.Invoking(async() => await SendAsync(command)).Should().Throw <UnauthorizedAccessException>(); }
public void AsBearbeiter_ShouldThrowValidationException() { RunAsBearbeiterUser(); UpdateVermittlerCommand command = CreateUpdateVermittlerCommandWithWrondValidations(); Func <Task> act = async() => { await SendAsync(command); }; act.Should().Throw <ValidationException>() .Which.Errors.Count().Should().Be(24); }
public async Task UpdateVermittlerCommand_ShouldThrowNotFoundException() { RunAsBearbeiterUser(); await CreateVermittlerAsync(); UpdateVermittlerCommand command = await CreateUpdateVermittlerCommandAsync(); command.Id = 4; FluentActions.Invoking(async() => await SendAsync(command)).Should().Throw <NotFoundException>(); }
public async Task UpdateVermittlerCommandAsBearbeiter_ShouldUpdateUpdatedFields() { RunAsBearbeiterUser(); await CreateVermittlerAsync(); UpdateVermittlerCommand command = await CreateUpdateVermittlerCommandAsync(); await SendAsync(command); var updatedVermittler = await FindVermittlerAsync(1); updatedVermittler.User.Telefon.Should().NotBeNullOrEmpty(); updatedVermittler.User.Anrede.Should().Be(Anrede.Herr); }
public async Task <ActionResult> UpdateVermittler(int id, [FromBody] UpdateVermittlerCommand command) { if (id != command.Id) { return(BadRequest()); } try { await Mediator.Send(command); return(NoContent()); } catch (NotFoundException ex) { return(NotFound(ex.Message)); } catch (UnauthorizedAccessException) { return(StatusCode(StatusCodes.Status401Unauthorized)); } }