コード例 #1
0
        public async Task AsAnonymous_ShouldReturnUnauthorizedAccessException()
        {
            await CreateVermittlerAsync();

            CreateOrUpdateDokumentFürVermittlerCommand command =
                await CreateDokumentFürVermittlerCommandAsync_NewDokument();

            FluentActions.Invoking(async() =>
                                   await SendAsync(command)).Should().Throw <UnauthorizedAccessException>();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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>();
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
            }
        }