Beispiel #1
0
        public void check_people_in_control_director_details_from_companies_house_are_returned()
        {
            var directorsFromCompaniesHouse = new List <PersonInControl>
            {
                new PersonInControl
                {
                    Name             = PersonInControlName + DirectorsPostfix + SourceExternal,
                    MonthYearOfBirth = PersonInControlDob + DirectorsPostfix + SourceExternal
                }
            };

            _organisationSummaryApiClient.Setup(x => x.GetDirectorsFromCompaniesHouse(_applicationId))
            .ReturnsAsync(directorsFromCompaniesHouse);

            var request  = new GetPeopleInControlRequest(_applicationId, UserId, UserName);
            var response = _orchestrator.GetPeopleInControlViewModel(request);

            var viewModel = response.Result;

            Assert.AreEqual(1, viewModel.CompanyDirectorsData.FromExternalSource.Count);

            Assert.AreEqual(viewModel.CompanyDirectorsData.FromExternalSource.First().Name,
                            directorsFromCompaniesHouse.First().Name);
            Assert.AreEqual(viewModel.CompanyDirectorsData.FromExternalSource.First().MonthYearOfBirth,
                            directorsFromCompaniesHouse.First().MonthYearOfBirth);
        }
Beispiel #2
0
        public void check_people_in_control_common_details_are_returned()
        {
            var request  = new GetPeopleInControlRequest(_applicationId, UserId, UserName);
            var response = _orchestrator.GetPeopleInControlViewModel(request);

            var viewModel = response.Result;

            Assert.AreEqual(GatewayPageId, viewModel.PageId);
            Assert.AreEqual(_applicationId, viewModel.ApplicationId);
            Assert.AreEqual(_commonDetails.Comments, viewModel.OptionFailText);
            Assert.Null(viewModel.OptionInProgressText);
            Assert.Null(viewModel.OptionClarificationText);
            Assert.Null(viewModel.OptionPassText);
            Assert.AreEqual(_commonDetails.Status, viewModel.Status);
            Assert.AreEqual(_commonDetails.Ukprn, viewModel.Ukprn);
            Assert.AreEqual(_commonDetails.LegalName, viewModel.ApplyLegalName);
        }
Beispiel #3
0
        public void Setup()
        {
            CoreSetup();
            _logger       = new Mock <ILogger <RoatpGatewayPeopleInControlController> >();
            _orchestrator = new Mock <IPeopleInControlOrchestrator>();
            ViewModel     = new PeopleInControlPageViewModel {
                ApplicationId = _applicationId
            };

            Request = new GetPeopleInControlRequest(_applicationId, UserId, Username);
            _orchestrator.Setup(x =>
                                x.GetPeopleInControlViewModel(It.IsAny <GetPeopleInControlRequest>()))
            .ReturnsAsync(ViewModel)
            .Verifiable("view model not returned");

            _controller = new RoatpGatewayPeopleInControlController(ApplyApiClient.Object, _logger.Object, GatewayValidator.Object, _orchestrator.Object);

            _controller.ControllerContext = MockedControllerContext.Setup();
            UserId   = _controller.ControllerContext.HttpContext.User.UserId();
            Username = _controller.ControllerContext.HttpContext.User.UserDisplayName();
        }
Beispiel #4
0
        public void check_people_in_control_whos_in_control_details_from_submitted_are_returned()
        {
            var whosInControlFromSubmitted = new List <PersonInControl>
            {
                new PersonInControl
                {
                    Name             = PersonInControlName + WhosInControlPostfix + SourceSubmitted,
                    MonthYearOfBirth = PersonInControlDob + WhosInControlPostfix + SourceSubmitted
                }
            };

            _organisationSummaryApiClient.Setup(x => x.GetWhosInControlFromSubmitted(_applicationId)).ReturnsAsync(whosInControlFromSubmitted);

            var request  = new GetPeopleInControlRequest(_applicationId, UserId, UserName);
            var response = _orchestrator.GetPeopleInControlViewModel(request);

            var viewModel = response.Result;

            Assert.AreEqual(1, viewModel.WhosInControlData.FromSubmittedApplication.Count);
            Assert.AreEqual(viewModel.WhosInControlData.FromSubmittedApplication.First().Name, whosInControlFromSubmitted.First().Name);
            Assert.AreEqual(viewModel.WhosInControlData.FromSubmittedApplication.First().MonthYearOfBirth, whosInControlFromSubmitted.First().MonthYearOfBirth);
        }
Beispiel #5
0
        public void check_people_in_control_trustee_details_from_charity_commission_are_returned()
        {
            var trusteesFromCharityCommission = new List <PersonInControl>
            {
                new PersonInControl
                {
                    Name = PersonInControlName + TrusteesPostfix + SourceExternal
                }
            };

            _organisationSummaryApiClient.Setup(x => x.GetTrusteesFromCharityCommission(_applicationId)).ReturnsAsync(trusteesFromCharityCommission);


            var request  = new GetPeopleInControlRequest(_applicationId, UserId, UserName);
            var response = _orchestrator.GetPeopleInControlViewModel(request);

            var viewModel = response.Result;

            Assert.AreEqual(1, viewModel.TrusteeData.FromExternalSource.Count);
            Assert.AreEqual(viewModel.TrusteeData.FromExternalSource.First().Name, trusteesFromCharityCommission.First().Name);
            Assert.AreEqual(viewModel.TrusteeData.FromExternalSource.First().MonthYearOfBirth, trusteesFromCharityCommission.First().MonthYearOfBirth);
        }
        public async Task <PeopleInControlPageViewModel> GetPeopleInControlViewModel(GetPeopleInControlRequest request)
        {
            _logger.LogInformation($"Retrieving people in control details for application {request.ApplicationId}");

            var model = new PeopleInControlPageViewModel();
            await model.PopulatePageCommonDetails(_applyApiClient, request.ApplicationId, GatewaySequences.PeopleInControlChecks,
                                                  GatewayPageIds.PeopleInControl,
                                                  request.UserId,
                                                  request.UserName,
                                                  RoatpGatewayConstants.Captions.PeopleInControlChecks,
                                                  RoatpGatewayConstants.Headings.PeopleInControl,
                                                  NoSelectionErrorMessages.Errors[GatewayPageIds.PeopleInControl]);

            _logger.LogInformation($"Retrieving people in control - type of organisation for application {request.ApplicationId}");
            model.TypeOfOrganisation = await _organisationSummaryApiClient.GetTypeOfOrganisation(request.ApplicationId);

            _logger.LogInformation($"Retrieving company number in control for application {request.ApplicationId}");
            model.CompanyNumber = await _organisationSummaryApiClient.GetCompanyNumber(request.ApplicationId);

            _logger.LogInformation($"Retrieving company number in control for application {request.ApplicationId}");
            model.CharityNumber = await _organisationSummaryApiClient.GetCharityNumber(request.ApplicationId);


            _logger.LogInformation($"Retrieving people in control - [{RoatpGatewayConstants.PeopleInControl.Heading.CompanyDirectors}] for application {request.ApplicationId}");
            model.CompanyDirectorsData = new PeopleInControlData
            {
                Caption = RoatpGatewayConstants.PeopleInControl.Heading.CompanyDirectors,
                ExternalSourceHeading    = RoatpGatewayConstants.PeopleInControl.Caption.CompaniesHouse,
                FromExternalSource       = await _organisationSummaryApiClient.GetDirectorsFromCompaniesHouse(request.ApplicationId),
                FromSubmittedApplication = await _organisationSummaryApiClient.GetDirectorsFromSubmitted(request.ApplicationId)
            };

            _logger.LogInformation($"Retrieving people in control - [{RoatpGatewayConstants.PeopleInControl.Heading.PeopleWithSignificantControl}] for application {request.ApplicationId}");
            model.PscData = new PeopleInControlData
            {
                Caption = RoatpGatewayConstants.PeopleInControl.Heading.PeopleWithSignificantControl,
                ExternalSourceHeading    = RoatpGatewayConstants.PeopleInControl.Caption.CompaniesHouse,
                FromExternalSource       = await _organisationSummaryApiClient.GetPscsFromCompaniesHouse(request.ApplicationId),
                FromSubmittedApplication = await _organisationSummaryApiClient.GetPscsFromSubmitted(request.ApplicationId)
            };

            _logger.LogInformation($"Retrieving people in control - [{RoatpGatewayConstants.PeopleInControl.Heading.Trustees}] for application {request.ApplicationId}");
            model.TrusteeData = new PeopleInControlData
            {
                Caption = RoatpGatewayConstants.PeopleInControl.Heading.Trustees,
                ExternalSourceHeading    = RoatpGatewayConstants.PeopleInControl.Caption.CharityCommission,
                FromExternalSource       = await _organisationSummaryApiClient.GetTrusteesFromCharityCommission(request.ApplicationId),
                FromSubmittedApplication = await _organisationSummaryApiClient.GetTrusteesFromSubmitted(request.ApplicationId)
            };

            _logger.LogInformation($"Retrieving people in control - [{RoatpGatewayConstants.PeopleInControl.Heading.WhosInControl}] for application {request.ApplicationId}");
            model.WhosInControlData = new PeopleInControlData
            {
                Caption = RoatpGatewayConstants.PeopleInControl.Heading.WhosInControl,
                ExternalSourceHeading    = null,
                FromExternalSource       = null,
                FromSubmittedApplication =
                    await _organisationSummaryApiClient.GetWhosInControlFromSubmitted(request.ApplicationId)
            };

            return(model);
        }