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.GetFinishEditingViewModel("ABC123", "XYZ123", "ABC321"); //Assert Assert.AreEqual(HttpStatusCode.BadRequest, actual.Status); }
public async Task ThenCountsShouldBeCorrectWhenEmployerHasASingleCommitmentThats( int expectedDraftCount, int expectedReadyForReviewCount, int expectedWithProviderCount, int expectedTransferFundedCohortsCount, int expectedRejectedTransferFundedCohortsCount, long?transferSenderId, TransferApprovalStatus transferApprovalStatus, AgreementStatus agreementStatus, EditStatus editStatus, LastAction lastAction, int apprenticeshipCount) { //Arrange MockMediator.Setup(x => x.SendAsync(It.IsAny <GetCommitmentsQuery>())) .ReturnsAsync(new GetCommitmentsResponse { Commitments = new List <CommitmentListItem> { new CommitmentListItem { TransferSenderId = transferSenderId, TransferApprovalStatus = transferApprovalStatus, AgreementStatus = agreementStatus, EditStatus = editStatus, LastAction = lastAction, ApprenticeshipCount = apprenticeshipCount } } }); //Act var result = await EmployerCommitmentOrchestrator.GetYourCohorts("ABC123", "ABC321"); //Assert Assert.AreEqual(expectedDraftCount, result.Data.DraftCount, "Incorrect DraftCount"); Assert.AreEqual(expectedReadyForReviewCount, result.Data.ReadyForReviewCount, "Incorrect ReadyForReviewCount"); Assert.AreEqual(expectedWithProviderCount, result.Data.WithProviderCount, "Incorrect WithProviderCount"); Assert.AreEqual(expectedTransferFundedCohortsCount, result.Data.TransferFundedCohortsCount, "IncorrectTransferFundedCohortsCount"); Assert.AreEqual(expectedRejectedTransferFundedCohortsCount, result.Data.RejectedTransferFundedCohortsCount, "IncorrectRejectedTransferFundedCohortsCount"); }
public async Task ShouldCallMediatorToDelete() { //Arrange var model = new DeleteApprenticeshipConfirmationViewModel { HashedAccountId = "ABC123", HashedCommitmentId = "ABC321", HashedApprenticeshipId = "ABC456" }; MockMediator.Setup(x => x.SendAsync(It.IsAny <GetApprenticeshipQueryRequest>())) .ReturnsAsync(new GetApprenticeshipQueryResponse { Apprenticeship = new Apprenticeship() }); MockMediator.Setup(x => x.SendAsync(It.IsAny <DeleteApprenticeshipCommand>())).ReturnsAsync(new Unit()); var expectedName = "Bob"; var expectedEmailAddress = "*****@*****.**"; //Act await EmployerCommitmentOrchestrator.DeleteApprenticeship(model, "externalUserId", expectedName, expectedEmailAddress); //Assert MockMediator.Verify( x => x.SendAsync( It.Is <DeleteApprenticeshipCommand>( c => c.AccountId == 123L && c.ApprenticeshipId == 456L && c.UserId == "externalUserId" && c.UserDisplayName == expectedName && c.UserEmailAddress == expectedEmailAddress)), Times.Once); }
public async Task ThenIsSecondApprovalShouldBeSetCorrectly(AgreementStatus agreementStatus, bool expectedIsSecondApproval) { CommitmentView.AgreementStatus = agreementStatus; var result = await EmployerCommitmentOrchestrator.GetAcknowledgementModelForExistingCommitment("ABC123", "XYZ123", "ABC321"); Assert.AreEqual(expectedIsSecondApproval, result.Data.IsSecondApproval); }
public async Task ThenFrameworksAreRetrievedForCohortsNotFundedByTransfer() { CommitmentView.TransferSender = null; await EmployerCommitmentOrchestrator.GetApprenticeship("HashedAccId", "ExtUserId", "HashedCmtId", "AppId"); MockMediator.Verify(x => x.SendAsync(It.Is <GetTrainingProgrammesQueryRequest>(r => r.IncludeFrameworks)), Times.Once); }
public async Task ThenIsTransferShouldntBeSetWhenTransferSenderIdHasNoValue() { //Act var result = await EmployerCommitmentOrchestrator.GetAcknowledgementModelForExistingCommitment("ABC123", "XYZ123", "ABC321"); //Assert Assert.IsFalse(result.Data.IsTransfer); }
public async Task ShouldReturnCorrectCreateCommitmentViewModel() { const string hashedAccountId = "HASHACC"; const string transferConnectionCode = "TCC"; const string legalEntityCode = "LECODE"; const long providerId = 123L; const string cohortRef = "COREF"; const string externalUserId = "USERID"; const long ukprn = 321L; const string providerName = "Pro Name"; const string legalEntityName = "LE Name"; const string legalEntityAddress = "LE Address"; const short legalEntitySourse = 1; const string accountLegalEntityPublicHashedId = "123456"; MockMediator.Setup(m => m.SendAsync(It.Is <GetProviderQueryRequest>(r => r.ProviderId == providerId))) .ReturnsAsync(new GetProviderQueryResponse { ProvidersView = new ProvidersView { Provider = new Provider { Ukprn = ukprn, ProviderName = providerName } } }); MockMediator.Setup(m => m.SendAsync(It.Is <GetAccountLegalEntitiesRequest>( r => r.HashedAccountId == hashedAccountId && r.UserId == externalUserId))) .ReturnsAsync(new GetAccountLegalEntitiesResponse { LegalEntities = new List <LegalEntity> { new LegalEntity { Code = legalEntityCode, Name = legalEntityName, RegisteredAddress = legalEntityAddress, Source = legalEntitySourse, AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId } } }); var response = await EmployerCommitmentOrchestrator.CreateSummary( hashedAccountId, transferConnectionCode, legalEntityCode, providerId.ToString(), cohortRef, externalUserId); Assert.AreEqual(hashedAccountId, response.Data.HashedAccountId); Assert.AreEqual(transferConnectionCode, response.Data.TransferConnectionCode); Assert.AreEqual(legalEntityCode, response.Data.LegalEntityCode); Assert.AreEqual(legalEntityName, response.Data.LegalEntityName); Assert.AreEqual(legalEntityAddress, response.Data.LegalEntityAddress); Assert.AreEqual(legalEntitySourse, response.Data.LegalEntitySource); Assert.AreEqual(accountLegalEntityPublicHashedId, response.Data.AccountLegalEntityPublicHashedId); Assert.AreEqual(ukprn, response.Data.ProviderId); Assert.AreEqual(providerName, response.Data.ProviderName); Assert.AreEqual(cohortRef, response.Data.CohortRef); }
public void ThenIfCohortIsNotForTransferThenIfApprovedByBothPartiesShouldThrowAnException() { CommitmentView.AgreementStatus = AgreementStatus.BothAgreed; CommitmentView.EditStatus = EditStatus.Both; CommitmentView.TransferSender = null; Assert.ThrowsAsync <InvalidStateException>(() => EmployerCommitmentOrchestrator.GetCommitmentDetails("HashedAccId", "HashedCmtId", "ExtUserId")); }
public async Task ThenDeleteButtonShouldBeVisible() { CommitmentView.AgreementStatus = AgreementStatus.NotAgreed; CommitmentView.EditStatus = EditStatus.EmployerOnly; var result = await EmployerCommitmentOrchestrator.GetCommitmentDetails("HashedAccId", "HashedCmtId", "ExtUserId"); Assert.IsFalse(result.Data.HideDeleteButton); }
public async Task ThenPageTitleShouldBeDictatedByEditStatus(EditStatus editStatus, bool expectReadOnly) { CommitmentView.AgreementStatus = AgreementStatus.NotAgreed; CommitmentView.EditStatus = editStatus; var result = await EmployerCommitmentOrchestrator.GetCommitmentDetails("HashedAccId", "HashedCmtId", "ExtUserId"); Assert.AreEqual(expectReadOnly, result.Data.IsReadOnly); }
public async Task ShouldCallMediatorWithExpectedQuery() { //Act await EmployerCommitmentOrchestrator.GetTransferRequestDetails("ABC123", CallerType.TransferSender, "XYZ789", "UserA"); //Assert MockMediator.Verify(x => x.SendAsync(It.Is <GetTransferRequestQueryRequest>(c => c.AccountId == 123 && c.TransferRequestId == 789 && c.CallerType == CallerType.TransferSender))); }
public async Task ThenItShouldReturnTheMappedTransferRequestViewModel() { //Arrange //Act var result = await EmployerCommitmentOrchestrator.GetTransferRequestDetails("ABC123", CallerType.TransferSender, "XYZ789", "UserA"); //Assert Assert.AreSame(_transferRequestViewModel, result.Data); }
public async Task ThenItShouldCallCommitmentMapperWithTransferRequestObject() { //Arrange //Act await EmployerCommitmentOrchestrator.GetTransferRequestDetails("ABC123", CallerType.TransferSender, "XYZ789", "UserA"); //Assert MockCommitmentMapper.Verify(x => x.MapToTransferRequestViewModel(_transferRequest)); }
public async Task ThenCommitmentDetailsShouldBeReturned() { MockHashingService.Setup(h => h.HashValue(CommitmentView.Id)).Returns("HashedCmtId"); var result = await EmployerCommitmentOrchestrator.GetCommitmentDetails("HashedAccId", "HashedCmtId", "ExtUserId"); Assert.AreEqual("HashedAccId", result.Data.HashedAccountId); Assert.AreEqual("HashedCmtId", result.Data.HashedId); Assert.AreEqual(CommitmentView.AccountLegalEntityPublicHashedId, result.Data.AccountLegalEntityPublicHashedId); }
public async Task ThenCohortTransferRejectionIsIndicated(TransferApprovalStatus status, bool expectRejectionIndicated) { CommitmentView.TransferSender = new TransferSender { TransferApprovalStatus = status }; var viewModel = await EmployerCommitmentOrchestrator.GetSkeletonApprenticeshipDetails("HashedAccId", "ExtUserId", "HashedCmtId"); Assert.AreEqual(expectRejectionIndicated, viewModel.Data.Apprenticeship.IsInTransferRejectedCohort); }
public async Task ThenIfCohortIsFundedByTransferThenTransferSenderPublicHashedIdShouldBeReturned() { CommitmentView.TransferSender = new TransferSender { Id = 123, TransferApprovalStatus = TransferApprovalStatus.Pending }; MockPublicHashingService.Setup(h => h.HashValue(CommitmentView.TransferSender.Id.Value)).Returns("HashedTrnId"); var result = await EmployerCommitmentOrchestrator.GetCommitmentDetails("HashedAccId", "HashedCmtId", "ExtUserId"); Assert.AreEqual("HashedTrnId", result.Data.TransferSenderPublicHashedId); }
public async Task ThenFrameworksAreNotRetrievedForCohortsFundedByTransfer() { CommitmentView.EditStatus = EditStatus.Both; CommitmentView.TransferSender = new TransferSender { Id = 123, TransferApprovalStatus = TransferApprovalStatus.Pending }; await EmployerCommitmentOrchestrator.GetCommitmentDetails("HashedAccId", "HashedCmtId", "ExtUserId"); MockMediator.Verify(x => x.SendAsync(It.Is <GetTrainingProgrammesQueryRequest>(r => !r.IncludeFrameworks)), Times.Once); }
public void ThenIfTheCohortWasApprovedByTransferSenderThenShouldThrowAnException() { CommitmentView.AgreementStatus = AgreementStatus.BothAgreed; CommitmentView.EditStatus = EditStatus.Both; CommitmentView.TransferSender = new TransferSender { TransferApprovalStatus = TransferApprovalStatus.Approved }; Assert.ThrowsAsync <InvalidStateException>(() => EmployerCommitmentOrchestrator.GetCommitmentDetails("HashedAccId", "HashedCmtId", "ExtUserId")); }
public async Task ShouldNotCallMediatorToCreateButReturnEmptyListIfFeatureToggleIsOff() { //Arrange _mockFeatureToggle.Setup(x => x.FeatureEnabled).Returns(false); //Act var list = await EmployerCommitmentOrchestrator.GetTransferConnections(HashedAccountId, UserId); //Assert Assert.IsEmpty(list.Data.TransferConnections); MockMediator.Verify(x => x.SendAsync(It.IsAny <GetAccountTransferConnectionsRequest>()), Times.Never); }
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 ThenPageTitleForTransferRejectedShouldBeReviewYourCohort() { CommitmentView.AgreementStatus = AgreementStatus.BothAgreed; CommitmentView.EditStatus = EditStatus.EmployerOnly; CommitmentView.TransferSender = new TransferSender { TransferApprovalStatus = TransferApprovalStatus.Rejected }; var result = await EmployerCommitmentOrchestrator.GetCommitmentDetails("HashedAccId", "HashedCmtId", "ExtUserId"); Assert.AreEqual("Review your cohort", result.Data.PageTitle); }
public async Task ThenEndDateShouldntBeValidatedIfNotSupplied() { MockApprenticeshipCoreValidator.Setup(v => v.MapOverlappingErrors(It.IsAny <GetOverlappingApprenticeshipsQueryResponse>())) .Returns(new Dictionary <string, string>()); var apprenticeship = new ApprenticeshipViewModel { EndDate = new DateTimeViewModel() }; var result = await EmployerCommitmentOrchestrator.ValidateApprenticeship(apprenticeship); CollectionAssert.AreEqual(new Dictionary <string, string>(), result); }
public async Task ThenIfTheCohortIsPendingTransferApprovalThenItIsReadOnly() { CommitmentView.AgreementStatus = AgreementStatus.BothAgreed; CommitmentView.EditStatus = EditStatus.Both; CommitmentView.TransferSender = new TransferSender { TransferApprovalStatus = TransferApprovalStatus.Pending }; var result = await EmployerCommitmentOrchestrator.GetCommitmentDetails("HashedAccId", "HashedCmtId", "ExtUserId"); Assert.IsTrue(result.Data.IsReadOnly); }
public async Task ShouldCallMediatorToCreateAndReturnListIfFeatureToggleIsOn() { //Arrange _mockFeatureToggle.Setup(x => x.FeatureEnabled).Returns(true); //Act var list = await EmployerCommitmentOrchestrator.GetTransferConnections(HashedAccountId, UserId); //Assert Assert.IsNotEmpty(list.Data.TransferConnections); Assert.AreEqual(1, list.Data.TransferConnections.Count()); MockMediator.Verify(x => x.SendAsync(It.Is <GetAccountTransferConnectionsRequest>(c => c.HashedAccountId == HashedAccountId && c.UserId == UserId)), 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); }
public async Task ThenIfTheCohortIsFundedByATransferThenDeleteButtonShouldBeHidden(TransferApprovalStatus status) { CommitmentView.AgreementStatus = AgreementStatus.BothAgreed; CommitmentView.EditStatus = EditStatus.EmployerOnly; CommitmentView.TransferSender = new TransferSender { Id = 123, TransferApprovalStatus = status }; var result = await EmployerCommitmentOrchestrator.GetCommitmentDetails("HashedAccId", "HashedCmtId", "ExtUserId"); Assert.IsTrue(result.Data.HideDeleteButton); }
public async Task ThenCorrectResultIsReturned(bool expectedResult, RequestStatus[] retrievedRequestStatuses, RequestStatus[] currentRequestStatus) { //Arrange MockMediator.Setup(x => x.SendAsync(It.IsAny <GetCommitmentsQuery>())) .ReturnsAsync(new GetCommitmentsResponse { Commitments = GetTestCommitmentsOfStatus(1, retrievedRequestStatuses).ToList() }); //Act var result = await EmployerCommitmentOrchestrator.AnyCohortsForCurrentStatus("ABC123", currentRequestStatus); //Assert Assert.AreEqual(expectedResult, result); }
public async Task ShouldCallMediatorToGetApprenticeship() { //Arrange MockMediator.Setup(x => x.SendAsync(It.IsAny <GetApprenticeshipQueryRequest>())) .ReturnsAsync(new GetApprenticeshipQueryResponse { Apprenticeship = new Apprenticeship() }); //Act await EmployerCommitmentOrchestrator.GetDeleteApprenticeshipViewModel("ABC123", "EXT789", "ABC321", "ABC456"); //Assert MockMediator.Verify(x => x.SendAsync(It.Is <GetApprenticeshipQueryRequest>(r => r.ApprenticeshipId == 456 && r.AccountId == 123))); }
public async Task ThenHasSignedAgreementIsCorrectlyDeterminedForNonTransfers(EmployerAgreementStatus v1, EmployerAgreementStatus v2, bool expectHasSigned) { //Arrange _commitmentView.TransferSender = null; MockMediator.Setup(x => x.SendAsync(It.IsAny <GetAccountLegalEntitiesRequest>())) .ReturnsAsync(MockLegalEntitiesResponse(v1, v2)); //Act var result = await EmployerCommitmentOrchestrator.GetFinishEditingViewModel("ABC123", "XYZ123", "ABC321"); //Assert Assert.AreEqual(expectHasSigned, result.Data.HasSignedTheAgreement); }
public async Task ShouldCallMediator() { //Arrange var model = new TransferApprovalConfirmationViewModel { ApprovalConfirmed = true }; //Act await EmployerCommitmentOrchestrator.SetTransferRequestApprovalStatus(HashedTransferSenderId, HashedCommitmentId, HashedTransferRequestId, model, "UserId", "UserName", "UserEmail"); //Assert MockMediator.Verify(x => x.SendAsync(It.Is <TransferApprovalCommand>(c => c.TransferSenderId == TransferSenderId && c.CommitmentId == CommitmentId && c.TransferRequestId == TransferRequestId && c.UserId == "UserId" && c.UserName == "UserName" && c.UserEmail == "UserEmail")), Times.Once); }