Exemplo n.º 1
0
        public async Task <ActionResult <int> > CreateDokumentFürVermittler(int id,
                                                                            [FromBody] CreateDokumentFürVermittlerCommand command)
        {
            if (id != command.VermittlerId)
            {
                return(BadRequest());
            }

            try
            {
                return(Ok(await Mediator.Send(command)));
            }
            catch (NotFoundException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (BadRequestException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (UnauthorizedAccessException)
            {
                return(StatusCode(StatusCodes.Status401Unauthorized));
            }
        }
Exemplo n.º 2
0
        public async Task AsAnonymous_ShouldReturnUnauthorizedAccessException()
        {
            await CreateVermittlerAsync();

            CreateDokumentFürVermittlerCommand command = await Create_CreateDokumentFürVermittlerCommandAsync();

            FluentActions.Invoking(async() =>
                                   await SendAsync(command)).Should().Throw <UnauthorizedAccessException>();
        }
Exemplo n.º 3
0
        public async Task AsAdmin_ShouldReturnNotFoundExceptionForUnknownDokumentArtId()
        {
            RunAsAdminUser();

            await CreateVermittlerAsync();

            CreateDokumentFürVermittlerCommand command =
                await Create_CreateDokumentFürVermittlerCommandAsync();

            command.DokumentArtId = 5;

            FluentActions.Invoking(async() =>
                                   await SendAsync(command)).Should().Throw <NotFoundException>();
        }
Exemplo n.º 4
0
        public async Task AsBearbeiter_ShouldThrowValidationException()
        {
            RunAsBearbeiterUser();

            await CreateVermittlerAsync();

            CreateDokumentFürVermittlerCommand command =
                await CreateInvalidCreateDokumentFürVermittlerCommandAsync();

            Func <Task> act = async() => { await SendAsync(command); };

            act.Should().Throw <ValidationException>()
            .Which.Errors.Count().Should().Be(6);
        }
Exemplo n.º 5
0
        public async Task AsAdmin_ShouldReturnBadRequestExceptionVermittlerAlreadyHasDokumentWithSameDokumentArt()
        {
            RunAsAdminUser();

            await CreateVermittlerAsync();

            CreateDokumentFürVermittlerCommand command =
                await Create_CreateDokumentFürVermittlerCommandAsync();

            command.DokumentArtId = 1;

            FluentActions.Invoking(async() =>
                                   await SendAsync(command)).Should().Throw <BadRequestException>();
        }
Exemplo n.º 6
0
        public async Task AsVermittler_ShouldCreateDokumentAndSetBearbeitungsstatusZuPrüfen()
        {
            RunAsVermittlerUser();

            await CreateVermittlerAsync();

            CreateDokumentFürVermittlerCommand command =
                await Create_CreateDokumentFürVermittlerCommandAsync();

            var result = await SendAsync(command);

            var dokumentFromRepo = await FindAsync <Dokument>(result);

            dokumentFromRepo.Should().NotBeNull();
            dokumentFromRepo.Bearbeitungsstatus.Should()
            .Be(Bearbeitungsstatus.ZuPrüfen);
        }
Exemplo n.º 7
0
        public async Task AsAdmin_ShouldCreateDokumentAndReturnIdOfCorrectDokument()
        {
            RunAsAdminUser();

            await CreateVermittlerAsync();

            CreateDokumentFürVermittlerCommand command =
                await Create_CreateDokumentFürVermittlerCommandAsync();

            var result = await SendAsync(command);

            var dokumentFromRepo = await FindAsync <Dokument>(result);

            dokumentFromRepo.Should().NotBeNull();
            dokumentFromRepo.Bearbeitungsstatus.Should()
            .Be(EnumExtensions.ParseEnumFromString <Bearbeitungsstatus>(command.Bearbeitungsstatus));
            dokumentFromRepo.Id.Should().Be(result);
        }