public async Task ThenIfTheCodeDoesNotExistTheResponseIsPopulatedAsBadRequest()
        {
            //Arrange
            MockMediator.Setup(x => x.SendAsync(It.IsAny <GetAccountLegalEntitiesRequest>()))
            .ReturnsAsync(new GetAccountLegalEntitiesResponse
            {
                LegalEntities = new List <LegalEntity> {
                    new LegalEntity
                    {
                        Code       = "XYZ1233",
                        Agreements = new List <Agreement>
                        {
                            new Agreement {
                                TemplateVersionNumber = 2, Status = EmployerAgreementStatus.Signed
                            }
                        }
                    }
                }
            });

            //Act
            var actual = await EmployerCommitmentOrchestrator.GetLegalEntitySignedAgreementViewModel("ABC123", null, "XYZ123", "C789", "123EDC");

            //Assert
            Assert.AreEqual(HttpStatusCode.BadRequest, actual.Status);
        }
        public async Task ShouldCallMediatorToGetLegalEntityAgreementRequest()
        {
            //Arrange
            MockMediator.Setup(x => x.SendAsync(It.IsAny <GetAccountLegalEntitiesRequest>()))
            .ReturnsAsync(MockLegalEntitiesResponse(EmployerAgreementStatus.Removed, EmployerAgreementStatus.Signed));

            //Act
            await EmployerCommitmentOrchestrator.GetLegalEntitySignedAgreementViewModel("ABC123", null, "123", "C789", "123EDC");

            //Assert
            MockMediator.Verify(x => x.SendAsync(It.Is <GetAccountLegalEntitiesRequest>(c => c.HashedAccountId == "ABC123" && c.UserId == "123EDC")), Times.Once);
        }
        public async Task ThenHasSignedAgreementIsCorrectlyDeterminedForTransfers(EmployerAgreementStatus v1,
                                                                                  EmployerAgreementStatus v2, bool expectHasSigned)
        {
            //Arrange
            MockMediator.Setup(x => x.SendAsync(It.IsAny <GetAccountLegalEntitiesRequest>()))
            .ReturnsAsync(MockLegalEntitiesResponse(v1, v2));

            //Act
            var result = await EmployerCommitmentOrchestrator.GetLegalEntitySignedAgreementViewModel("ABC123", "789FGH", "123", "C789", "123EDC");


            //Assert
            Assert.AreEqual(expectHasSigned, result.Data.HasSignedAgreement);
        }
示例#4
0
        public async Task ThenTheViewModelShouldReflectWhetherTheAgreementHasBeenSigned(bool isSigned)
        {
            //Arrange
            MockMediator.Setup(x => x.SendAsync(It.IsAny <GetLegalEntityAgreementRequest>()))
            .ReturnsAsync(new GetLegalEntityAgreementResponse
            {
                EmployerAgreement = isSigned ? null : new EmployerAgreementView()
            });

            //Act
            var result = await EmployerCommitmentOrchestrator.GetLegalEntitySignedAgreementViewModel("ABC123", "XYZ123", "C789");

            //Assert
            Assert.AreEqual(isSigned, result.Data.HasSignedAgreement);
        }
示例#5
0
        public async Task ShouldCallMediatorToGetLegalEntityAgreementRequest()
        {
            //Arrange
            MockMediator.Setup(x => x.SendAsync(It.IsAny <GetLegalEntityAgreementRequest>()))
            .ReturnsAsync(new GetLegalEntityAgreementResponse
            {
                EmployerAgreement = new EmployerAgreementView()
            });

            //Act
            await EmployerCommitmentOrchestrator.GetLegalEntitySignedAgreementViewModel("ABC123", "123", "C789");

            //Assert
            MockMediator.Verify(x => x.SendAsync(It.Is <GetLegalEntityAgreementRequest>(c => c.AccountId == 123L && c.LegalEntityCode == "123")), Times.Once);
        }
        public async Task ThenIfAnInvalidRequestExceptionIsThrownThenTheOrchestratorResponseIsPopulatedAsBadRequest()
        {
            //Arrange
            MockMediator.Setup(x => x.SendAsync(It.IsAny <GetAccountLegalEntitiesRequest>()))
            .ThrowsAsync(new InvalidRequestException(new Dictionary <string, string> {
                { "", "" }
            }));

            //Act
            var actual = await EmployerCommitmentOrchestrator.GetLegalEntitySignedAgreementViewModel("ABC123", null, "XYZ123", "C789", "123EDC");

            //Assert
            Assert.AreEqual(HttpStatusCode.BadRequest, actual.Status);
            Assert.AreEqual(1, actual.FlashMessage.ErrorMessages.Count);
        }
        public async Task ShouldMapTransferConnectionCodeToResponse()
        {
            //Arrange
            MockMediator.Setup(x => x.SendAsync(It.IsAny <GetAccountLegalEntitiesRequest>()))
            .ReturnsAsync(new GetAccountLegalEntitiesResponse
            {
                LegalEntities = new List <LegalEntity> {
                    new LegalEntity {
                        Code = "123", Agreements = new List <Agreement>()
                    }
                }
            });

            //Act
            var result = await EmployerCommitmentOrchestrator.GetLegalEntitySignedAgreementViewModel("ABC123", "T1234", "123", "C789", "123EDC");

            //Assert
            result.Data.TransferConnectionCode.Should().Be("T1234");
        }