public async Task AsAnonymous_ShouldReturnUnauthorizedAccessException() { await CreateVermittlerAsync(); CreateOrUpdateDokumentFürVermittlerCommand command = await CreateDokumentFürVermittlerCommandAsync_NewDokument(); FluentActions.Invoking(async() => await SendAsync(command)).Should().Throw <UnauthorizedAccessException>(); }
public async Task ShouldThrowValidationException() { await CreateVermittlerAsync(); CreateOrUpdateDokumentFürVermittlerCommand command = await InvalidCreateOrUpdateDokumentFürVermittlerCommandAsync(); Func <Task> act = async() => { await SendAsync(command); }; act.Should().Throw <ValidationException>() .Which.Errors.Count().Should().Be(5); }
public async Task AsNewVermittler_NotRegistered_ShouldReturnNotFoundException() { RunAsNewVermittler(); await CreateVermittlerAsync(); CreateOrUpdateDokumentFürVermittlerCommand command = await CreateDokumentFürVermittlerCommandAsync_NewDokument(); command.VermittlerId = -1; FluentActions.Invoking(async() => await SendAsync(command)).Should().Throw <NotFoundException>(); }
public async Task AsNewVermittler_ShouldCreateDokumentAndSetBearbeitungsstatusZuPrüfen() { RunAsNewVermittler(); await CreateNeuerVermittlerAsync(); CreateOrUpdateDokumentFürVermittlerCommand command = await CreateDokumentFürVermittlerCommandAsync_NewDokument(); var result = await SendAsync(command); var dokumentFromRepo = await FindAsync <Dokument>(result); dokumentFromRepo.Should().NotBeNull(); dokumentFromRepo.Bearbeitungsstatus.Should() .Be(Bearbeitungsstatus.ZuPrüfen); dokumentFromRepo.Name.Should().Be(command.Name); }
public async Task <ActionResult <int> > CreateOrUpdateDokumentFürVermittler(int id, [FromBody] CreateOrUpdateDokumentFürVermittlerCommand command) { if (id != command.VermittlerId) { return(BadRequest()); } try { return(Ok(await Mediator.Send(command))); } catch (NotFoundException ex) { return(NotFound(ex.Message)); } catch (UnauthorizedAccessException) { return(StatusCode(StatusCodes.Status401Unauthorized)); } }