public void Then_adds_levy_flag_To_query_string_if_no_course_or_start_date_provided( Guid reservationId, string accountLegalEntityPublicHashedId, string accountHashedId, [Frozen] ReservationsWebConfiguration webConfig, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("employer"); var originalConfigUrl = webConfig.EmployerApprenticeUrl; webConfig.EmployerApprenticeUrl = $"https://{webConfig.EmployerApprenticeUrl}"; var actualUrl = urlHelper.GenerateAddApprenticeUrl(reservationId, accountLegalEntityPublicHashedId, "", null, null, "", accountHashedId); Assert.AreEqual( $"https://{originalConfigUrl}/{accountHashedId}/unapproved/add?reservationId={reservationId}&accountLegalEntityHashedId={accountLegalEntityPublicHashedId}&autocreated=true", actualUrl); }
public void Then_Adds_The_TransferSenderId_If_It_Has_Been_Provided( Guid reservationId, string accountLegalEntityPublicHashedId, string courseId, string transferSenderId, uint ukPrn, DateTime startDate, [Frozen] ReservationsWebConfiguration webConfig, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("provider"); var originalConfigUrl = webConfig.ApprenticeUrl; webConfig.ApprenticeUrl = $"https://{webConfig.ApprenticeUrl}"; var actualUrl = urlHelper.GenerateAddApprenticeUrl(reservationId, accountLegalEntityPublicHashedId, courseId, ukPrn, startDate, "", "", false, transferSenderId); Assert.AreEqual( $"https://{originalConfigUrl}/{ukPrn}/unapproved/add/apprentice?reservationId={reservationId}&employerAccountLegalEntityPublicHashedId={accountLegalEntityPublicHashedId}&startMonthYear={startDate:MMyyyy}&courseCode={courseId}&transferSenderId={transferSenderId}", actualUrl); }
public void Then_Uses_Unapproved_Controller_With_Cohort_Ref_When_There_Is_A_Cohort_Ref( Guid reservationId, string accountLegalEntityPublicHashedId, string courseId, uint ukPrn, DateTime startDate, string cohortRef, [Frozen] ReservationsWebConfiguration webConfig, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("provider"); var originalConfigUrl = webConfig.ApprenticeUrl; webConfig.ApprenticeUrl = $"https://{webConfig.ApprenticeUrl}"; var actualUrl = urlHelper.GenerateAddApprenticeUrl(reservationId, accountLegalEntityPublicHashedId, courseId, ukPrn, startDate, cohortRef, ""); Assert.AreEqual( $"https://{originalConfigUrl}/{ukPrn}/unapproved/{cohortRef}/apprentices/add?reservationId={reservationId}&employerAccountLegalEntityPublicHashedId={accountLegalEntityPublicHashedId}&startMonthYear={startDate:MMyyyy}&courseCode={courseId}", actualUrl); }
public void Then_Uses_Unapproved_Add_Apprentice_For_Select_Journey_With_Empty_Cohort( Guid reservationId, string accountLegalEntityPublicHashedId, string accountHashedId, string courseId, uint ukPrn, DateTime startDate, [Frozen] ReservationsWebConfiguration webConfig, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("employer"); var originalConfigUrl = webConfig.EmployerApprenticeUrl; webConfig.EmployerApprenticeUrl = $"https://{webConfig.EmployerApprenticeUrl}"; var actualUrl = urlHelper.GenerateAddApprenticeUrl(reservationId, accountLegalEntityPublicHashedId, courseId, ukPrn, startDate, "", accountHashedId, true); Assert.AreEqual( $"https://{originalConfigUrl}/{accountHashedId}/unapproved/add/apprentice?reservationId={reservationId}&accountLegalEntityHashedId={accountLegalEntityPublicHashedId}&providerId={ukPrn}&startMonthYear={startDate:MMyyyy}&courseCode={courseId}", actualUrl); }
public void Then_CourseCode_And_StartDate_Are_Not_Added_To_Query_String_If_Not_Supplied( Guid reservationId, string accountLegalEntityPublicHashedId, uint ukPrn, [Frozen] ReservationsWebConfiguration webConfig, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("provider"); var originalConfigUrl = webConfig.ApprenticeUrl; webConfig.ApprenticeUrl = $"https://{webConfig.ApprenticeUrl}"; var actualUrl = urlHelper.GenerateAddApprenticeUrl(reservationId, accountLegalEntityPublicHashedId, "", ukPrn, null, "", ""); Assert.AreEqual( $"https://{originalConfigUrl}/{ukPrn}/unapproved/add/apprentice?reservationId={reservationId}&employerAccountLegalEntityPublicHashedId={accountLegalEntityPublicHashedId}&autocreated=true", actualUrl); }
public ManageReservationsController( IMediator mediator, IEncodingService encodingService, IExternalUrlHelper urlHelper, IOptions <ReservationsWebConfiguration> configuration, ILogger <ManageReservationsController> logger) { _mediator = mediator; _encodingService = encodingService; _urlHelper = urlHelper; _configuration = configuration.Value; _logger = logger; }
public EmployerReservationsController( IMediator mediator, IEncodingService encodingService, IOptions <ReservationsWebConfiguration> options, IExternalUrlHelper urlHelper, ILogger <EmployerReservationsController> logger) { _mediator = mediator; _encodingService = encodingService; _urlHelper = urlHelper; _logger = logger; _config = options.Value; }
public void Then_Uses_ProviderUrl_And_Params_To_Build_Employer_Url( [Frozen] ReservationsWebConfiguration webConfig, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("provider"); webConfig.DashboardUrl = $"https://{webConfig.DashboardUrl}"; var actualUrl = urlHelper.GenerateDashboardUrl(); Assert.AreEqual( $"{webConfig.DashboardUrl}/Account", actualUrl); }
public void Arrange() { _mockMediator = new Mock <IMediator>(); _config = new ReservationsWebConfiguration { EmployerDashboardUrl = "test.com/test" }; var options = new Mock <IOptions <ReservationsWebConfiguration> >(); options.Setup(o => o.Value).Returns(_config); _controller = new ProviderReservationsController(_mockMediator.Object, Mock.Of <IExternalUrlHelper>()); }
public async Task And_Has_Ukprn_Then_Returns_List_Of_Reservations_For_All_Trusted_Employer_Accounts( [Frozen] ReservationsRouteModel routeModel, GetTrustedEmployersResponse getTrustedEmployersResponse, [ReservationsFromThisProvider] GetReservationsResult getReservationsResult1, [ReservationsFromThisProvider] GetReservationsResult getReservationsResult2, [ReservationsFromThisProvider] GetReservationsResult getReservationsResult3, string hashedId, string homeLink, [Frozen] ReservationsWebConfiguration config, [Frozen] Mock <IExternalUrlHelper> externalUrlHelper, [Frozen] Mock <IEncodingService> mockEncodingService, [Frozen] Mock <IMediator> mockMediator, ManageReservationsController controller) { mockMediator .Setup(mediator => mediator.Send(It.IsAny <GetTrustedEmployersQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(getTrustedEmployersResponse); mockMediator .SetupSequence(mediator => mediator.Send(It.IsAny <GetReservationsQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(getReservationsResult1) .ReturnsAsync(getReservationsResult2) .ReturnsAsync(getReservationsResult3); mockEncodingService .Setup(service => service.Encode(It.IsAny <long>(), EncodingType.PublicAccountLegalEntityId)) .Returns(hashedId); externalUrlHelper .Setup(x => x.GenerateDashboardUrl(routeModel.EmployerAccountId)).Returns(homeLink); var expectedReservations = new List <ReservationViewModel>(); expectedReservations.AddRange(getReservationsResult1.Reservations.Select(reservation => new ReservationViewModel(reservation, config.ApprenticeUrl, routeModel.UkPrn))); expectedReservations.AddRange(getReservationsResult2.Reservations.Select(reservation => new ReservationViewModel(reservation, config.ApprenticeUrl, routeModel.UkPrn))); expectedReservations.AddRange(getReservationsResult3.Reservations.Select(reservation => new ReservationViewModel(reservation, config.ApprenticeUrl, routeModel.UkPrn))); var result = await controller.Manage(routeModel) as ViewResult; result.Should().NotBeNull(); result.ViewName.Should().Be(ViewNames.ProviderManage); var viewModel = result.Model as ManageViewModel; viewModel.Should().NotBeNull(); viewModel.BackLink.Should().Be(homeLink); viewModel.Reservations.Should().BeEquivalentTo(expectedReservations, options => options.ExcludingMissingMembers().ExcludingFields().Excluding(c => c.ApprenticeUrl)); }
public void Then_Takes_You_Unapproved_Add_Assign_When_There_Is_No_CohortRef( string accountId, [Frozen] ReservationsWebConfiguration options, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("employer"); options.EmployerDashboardUrl = $"https://{options.EmployerDashboardUrl}"; var actualUrl = urlHelper.GenerateCohortDetailsUrl(null, accountId, ""); Assert.AreEqual( $"{options.EmployerDashboardUrl}/commitments/accounts/{accountId}/unapproved/add/assign", actualUrl); }
public ReservationsController( IMediator mediator, ITrainingDateService trainingDateService, IOptions <ReservationsWebConfiguration> configuration, ILogger <ReservationsController> logger, IEncodingService encodingService, IExternalUrlHelper urlHelper) : base(mediator) { _mediator = mediator; _trainingDateService = trainingDateService; _logger = logger; _encodingService = encodingService; _configuration = configuration.Value; _urlHelper = urlHelper; }
public void Then_Uses_Folder_When_There_Is_No_Ukprn( string accountId, string cohortRef, [Frozen] ReservationsWebConfiguration options, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("employer"); options.EmployerDashboardUrl = $"https://{options.EmployerDashboardUrl}"; var actualUrl = urlHelper.GenerateCohortDetailsUrl(null, accountId, cohortRef); Assert.AreEqual( $"{options.EmployerDashboardUrl}/commitments/accounts/{accountId}/apprentices/{cohortRef}/details", actualUrl); }
public void Then_Uses_No_Folder_When_There_Is_A_Ukprn( uint ukprn, string cohortRef, [Frozen] ReservationsWebConfiguration options, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("provider"); options.DashboardUrl = $"https://{options.DashboardUrl}"; var actualUrl = urlHelper.GenerateCohortDetailsUrl(ukprn, "", cohortRef); Assert.AreEqual( $"{options.DashboardUrl}/{ukprn}/apprentices/{cohortRef}/details", actualUrl); }
public void Then_Uses_Folder_When_There_Is_A_Ukprn_And_Is_Empty_Cohort_Journey( string accountId, uint ukprn, [Frozen] ReservationsWebConfiguration options, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("employer"); options.EmployerDashboardUrl = $"https://{options.EmployerDashboardUrl}"; var actualUrl = urlHelper.GenerateCohortDetailsUrl(ukprn, accountId, string.Empty, true); Assert.AreEqual( $"{options.EmployerDashboardUrl}/commitments/accounts/{accountId}/unapproved/add?providerId={ukprn}", actualUrl); }
public void Then_Uses_EmployerUrl_And_Params_To_Build_Employer_Url( string accountId, [Frozen] ReservationsWebConfiguration webConfig, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("employer"); var originalConfigUrl = webConfig.EmployerDashboardUrl; webConfig.EmployerDashboardUrl = $"https://{webConfig.EmployerDashboardUrl}"; var actualUrl = urlHelper.GenerateDashboardUrl(accountId); Assert.AreEqual( $"https://accounts.{originalConfigUrl}/accounts/{accountId}/teams", actualUrl); }
public void Arrange() { var fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true }); _mockMediator = fixture.Freeze <Mock <IMediator> >(); _employerConfig = new ReservationsWebConfiguration { EmployerDashboardUrl = "test.com/test" }; var options = fixture.Freeze <Mock <IOptions <ReservationsWebConfiguration> > >(); options.Setup(o => o.Value).Returns(_employerConfig); _controller = fixture.Create <EmployerReservationsController>(); }
public void Then_Uses_EmployerApprenticeUrl_And_Params_To_Build_Employer_Url( UrlParameters urlParameters, [Frozen] ReservationsWebConfiguration webConfig, [Frozen] Mock <IConfiguration> config, ExternalUrlHelper urlHelper) { config.Setup(x => x["AuthType"]).Returns("employer"); var originalConfigUrl = webConfig.EmployerApprenticeUrl; webConfig.EmployerApprenticeUrl = $"https://{webConfig.EmployerApprenticeUrl}"; var actualUrl = urlHelper.GenerateAddApprenticeUrl(urlParameters); Assert.AreEqual( $"https://{urlParameters.SubDomain}.{originalConfigUrl}/{urlParameters.Folder}/{urlParameters.Id}/{urlParameters.Controller}/{urlParameters.Action}{urlParameters.QueryString}", actualUrl); }
public void Arrange() { var fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true }); _expectedRule = new GlobalRule { Id = 2, ActiveFrom = DateTime.Now.AddDays(2) }; var result = new GetNextUnreadGlobalFundingRuleResult { Rule = _expectedRule }; _mockMediator = fixture.Freeze <Mock <IMediator> >(); _config = new ReservationsWebConfiguration { DashboardUrl = "test.com/test" }; var options = fixture.Freeze <Mock <IOptions <ReservationsWebConfiguration> > >(); options.Setup(o => o.Value).Returns(_config); _mockMediator.Setup(x => x.Send(It.IsAny <GetNextUnreadGlobalFundingRuleQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(result); _externalUrlHelper = fixture.Freeze <Mock <IExternalUrlHelper> >(); _externalUrlHelper.Setup(x => x.GenerateDashboardUrl(null)).Returns(ExpectedDashboardUrl); _urlHelper = fixture.Freeze <Mock <IUrlHelper> >(); _urlHelper.Setup(h => h.RouteUrl(It.Is <UrlRouteContext>(c => c.RouteName.Equals(RouteNames.ProviderManage)))) .Returns(ExpectedManageUrl); _controller = fixture.Create <ProviderReservationsController>(); var claim = new Claim(ProviderClaims.ProviderUkprn, ExpectedUkPrn); _controller.ControllerContext.HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(new ClaimsIdentity(new[] { claim })) }; }
public async Task Then_Returns_List_Of_Reservations_From_Mediator( [Frozen] ReservationsRouteModel routeModel, ManageReservationsFilterModel filterModel, SearchReservationsResult searchResult, string hashedId, string homeLink, [Frozen] ReservationsWebConfiguration config, [Frozen] Mock <IExternalUrlHelper> externalUrlHelper, [Frozen] Mock <IEncodingService> mockEncodingService, [Frozen] Mock <IMediator> mockMediator, ManageReservationsController controller) { mockMediator .Setup(mediator => mediator.Send(It.IsAny <SearchReservationsQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(searchResult); mockEncodingService .Setup(service => service.Encode(It.IsAny <long>(), EncodingType.PublicAccountLegalEntityId)) .Returns(hashedId); externalUrlHelper .Setup(x => x.GenerateDashboardUrl(routeModel.EmployerAccountId)).Returns(homeLink); var expectedReservations = new List <ReservationViewModel>(); expectedReservations.AddRange(searchResult.Reservations.Select(reservation => new ReservationViewModel(reservation, config.ApprenticeUrl, routeModel.UkPrn))); var result = await controller.ProviderManage(routeModel, filterModel) as ViewResult; result.Should().NotBeNull(); result.ViewName.Should().Be(ViewNames.ProviderManage); var viewModel = result.Model as ManageViewModel; viewModel.Should().NotBeNull(); viewModel.TotalReservationCount.Should().Be(searchResult.TotalReservationsForProvider); viewModel.BackLink.Should().Be(homeLink); viewModel.FilterModel.NumberOfRecordsFound.Should().Be(searchResult.NumberOfRecordsFound); viewModel.Reservations.Should().BeEquivalentTo(expectedReservations, options => options.ExcludingFields().Excluding(c => c.ApprenticeUrl)); viewModel.FilterModel.EmployerFilters.Should().BeEquivalentTo(searchResult.EmployerFilters); viewModel.FilterModel.CourseFilters.Should().BeEquivalentTo(searchResult.CourseFilters); viewModel.FilterModel.StartDateFilters.Should().BeEquivalentTo(searchResult.StartDateFilters); }
public ExtendedIdentityServerAnchorTagHelper(IHtmlGenerator generator, IOptions <IdentityServerConfiguration> options, IOptions <ReservationsWebConfiguration> webOptions) : base(generator) { _generator = generator; _webOptions = webOptions.Value; _options = options.Value; }
public ExternalUrlHelper(IOptions <ReservationsWebConfiguration> options, IConfiguration configuration) { _configuration = configuration; _options = options.Value; }