public async Task Then_Conflict_is_returned_when_uln_already_submitted(
            long accountId,
            ConfirmApplicationRequest request,
            CreateAccountLegalEntityCommandResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] ApplicationController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <ConfirmApplicationCommand>(c =>
                                                         c.AccountId.Equals(request.AccountId) &&
                                                         c.ApplicationId.Equals(request.ApplicationId) &&
                                                         c.DateSubmitted.Equals(request.DateSubmitted)),
                       It.IsAny <CancellationToken>()))
            .ThrowsAsync(new UlnAlreadySubmittedException());

            var controllerResult = await controller.ConfirmApplication(request) as ConflictObjectResult;

            Assert.IsNotNull(controllerResult);
        }
        public async Task Then_ConfirmApplicationCommand_is_handled(
            long accountId,
            ConfirmApplicationRequest request,
            CreateAccountLegalEntityCommandResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] ApplicationController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <ConfirmApplicationCommand>(c =>
                                                         c.AccountId.Equals(request.AccountId) &&
                                                         c.ApplicationId.Equals(request.ApplicationId) &&
                                                         c.DateSubmitted.Equals(request.DateSubmitted)),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(Unit.Value);

            var controllerResult = await controller.ConfirmApplication(request) as StatusCodeResult;

            Assert.IsNotNull(controllerResult);
            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
        }
示例#3
0
        public async Task Then_Creates_Account_LegalEntity_From_Mediator(
            long accountId,
            LegalEntityRequest legalEntityRequest,
            CreateAccountLegalEntityCommandResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] AccountController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <CreateAccountLegalEntityCommand>(c =>
                                                               c.AccountId.Equals(accountId) &&
                                                               c.OrganisationName.Equals(legalEntityRequest.OrganisationName) &&
                                                               c.LegalEntityId.Equals(legalEntityRequest.LegalEntityId) &&
                                                               c.AccountLegalEntityId.Equals(legalEntityRequest.AccountLegalEntityId)),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var controllerResult = await controller.AddLegalEntity(accountId, legalEntityRequest) as ObjectResult;

            Assert.IsNotNull(controllerResult);
            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.Created);
        }