public async Task Then_If_The_Id_Is_Null_Or_Empty_Then_The_RouteModel_Is_Checked_For_The_Id( string accountLegalEntityId, string dashboardUrl, GetAccountLegalEntityResult result, [Frozen] Mock <IExternalUrlHelper> externalUrlHelper, [Frozen] Mock <IMediator> mediator, ReservationsRouteModel routeModel, ProviderReservationsController controller, EmployerAgreementNotSignedViewModel viewModel) { //Arrange result.LegalEntity.AgreementSigned = false; externalUrlHelper.Setup(x => x.GenerateDashboardUrl(null)).Returns(dashboardUrl); mediator.Setup(x => x.Send( It.Is <GetAccountLegalEntityQuery>(c => c.AccountLegalEntityPublicHashedId.Equals(accountLegalEntityId)), It.IsAny <CancellationToken>())).ReturnsAsync(result); routeModel.AccountLegalEntityPublicHashedId = accountLegalEntityId; //Act var actual = await controller.EmployerAgreementNotSigned(routeModel, ""); //Assert Assert.IsNotNull(actual); var viewResult = actual as ViewResult; Assert.IsNotNull(viewResult); var model = viewResult.Model as EmployerAgreementNotSignedViewModel; Assert.IsNotNull(model); model.AccountName.Should().Be(result.LegalEntity.AccountLegalEntityName); model.DashboardUrl.Should().Be(dashboardUrl); mediator.Verify(x => x.Send(It.IsAny <GetAccountLegalEntityQuery>(), It.IsAny <CancellationToken>()), Times.Once); }
public async Task <IActionResult> EmployerAgreementNotSigned(ReservationsRouteModel routeModel, string id) { if (string.IsNullOrEmpty(id)) { id = routeModel.AccountLegalEntityPublicHashedId; } var result = await _mediator.Send(new GetAccountLegalEntityQuery { AccountLegalEntityPublicHashedId = id }); var viewModel = new EmployerAgreementNotSignedViewModel { AccountName = result.LegalEntity.AccountLegalEntityName, DashboardUrl = _externalUrlHelper.GenerateDashboardUrl(null), BackUrl = routeModel.IsFromSelect.HasValue && routeModel.IsFromSelect.Value ? routeModel.PreviousPage : "", IsUrl = routeModel.IsFromSelect.HasValue && routeModel.IsFromSelect.Value }; return(View(viewModel)); }
public async Task Then_If_The_User_Has_Come_From_Select_Reservation_The_BackUrl_Is_Populated( string accountLegalEntityId, string dashboardUrl, string previousPageUrl, GetAccountLegalEntityResult result, [Frozen] Mock <IExternalUrlHelper> externalUrlHelper, [Frozen] Mock <IMediator> mediator, ReservationsRouteModel routeModel, ProviderReservationsController controller, EmployerAgreementNotSignedViewModel viewModel) { //Arrange result.LegalEntity.AgreementSigned = false; externalUrlHelper.Setup(x => x.GenerateDashboardUrl(null)).Returns(dashboardUrl); mediator.Setup(x => x.Send( It.Is <GetAccountLegalEntityQuery>(c => c.AccountLegalEntityPublicHashedId.Equals(accountLegalEntityId)), It.IsAny <CancellationToken>())).ReturnsAsync(result); routeModel.AccountLegalEntityPublicHashedId = accountLegalEntityId; routeModel.IsFromSelect = true; routeModel.PreviousPage = previousPageUrl; //Act var actual = await controller.EmployerAgreementNotSigned(routeModel, ""); //Assert Assert.IsNotNull(actual); var viewResult = actual as ViewResult; Assert.IsNotNull(viewResult); var model = viewResult.Model as EmployerAgreementNotSignedViewModel; Assert.IsNotNull(model); model.AccountName.Should().Be(result.LegalEntity.AccountLegalEntityName); model.BackUrl.Should().Be(previousPageUrl); }