Ejemplo n.º 1
0
        public async Task And_EntityNotFoundException_Then_Returns_NotFound(
            long accountId,
            EntityNotFoundException <AccountLegalEntity> notFoundException,
            [Frozen] Mock <IMediator> mockMediator,
            AccountLegalEntitiesController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetAccountReservationStatusQuery>(query => query.AccountId == accountId),
                       It.IsAny <CancellationToken>()))
            .ThrowsAsync(notFoundException);

            var result = await controller.GetAccountReservationStatus(accountId, null) as NotFoundResult;

            result.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }
Ejemplo n.º 2
0
        public async Task Then_Returns_AccountReservationStatus(
            long accountId,
            GetAccountReservationStatusResponse response,
            [Frozen] Mock <IMediator> mockMediator,
            AccountLegalEntitiesController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetAccountReservationStatusQuery>(query => query.AccountId == accountId),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(response);

            var result = await controller.GetAccountReservationStatus(accountId, null) as OkObjectResult;

            result.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var model = result.Value as AccountReservationStatus;

            model.Should().BeEquivalentTo(new AccountReservationStatus(response));
        }
Ejemplo n.º 3
0
        public async Task And_ArgumentException_Then_Returns_BadRequest(
            long accountId,
            ArgumentException argumentException,
            [Frozen] Mock <IMediator> mockMediator,
            AccountLegalEntitiesController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetAccountReservationStatusQuery>(query => query.AccountId == accountId),
                       It.IsAny <CancellationToken>()))
            .ThrowsAsync(argumentException);

            var result = await controller.GetAccountReservationStatus(accountId, null) as BadRequestObjectResult;

            result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
            var model = result.Value.Should().BeOfType <ArgumentErrorViewModel>().Subject;

            model.Message.Should().Be(argumentException.Message);
            model.Params.Should().Be(argumentException.ParamName);
        }