Ejemplo n.º 1
0
        public async Task ThenTheValuesWillBeCorrectlyMappedInTheResponse()
        {
            //Arrange
            var request = new SelectEmployerViewModel {
                EmployerRef = "251643"
            };
            var response = new GetEmployerInformationResponse
            {
                CompanyStatus       = "active",
                AddressLine1        = "address1",
                AddressLine2        = "address2",
                AddressPostcode     = "ADD123",
                CompanyName         = "Company Name",
                CompanyNumber       = "ABC12345",
                DateOfIncorporation = DateTime.MaxValue
            };

            _mediator.Setup(x => x.SendAsync(It.IsAny <GetEmployerInformationRequest>())).ReturnsAsync(response);

            //Act
            var actual = await _employerAccountOrchestrator.GetCompanyDetails(request);

            //Assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(response.DateOfIncorporation, actual.Data.DateOfInception);
            Assert.AreEqual(response.CompanyStatus, actual.Data.Status);
            Assert.AreEqual($"{response.AddressLine1}, {response.AddressLine2}, {response.AddressPostcode}", actual.Data.Address);
            Assert.AreEqual(response.CompanyName, actual.Data.Name);
            Assert.AreEqual(response.CompanyNumber, actual.Data.ReferenceNumber);
        }
Ejemplo n.º 2
0
        public void Assert_SelectEmployerViewModelCorrectlyMapped(SelectEmployerViewModel result)
        {
            Assert.AreEqual(_apiResponse.AccountProviderLegalEntities.Count(), result.AccountProviderLegalEntities.Count());

            foreach (var entity in _apiResponse.AccountProviderLegalEntities)
            {
                Assert.True(result.AccountProviderLegalEntities.Any(x =>
                                                                    x.EmployerAccountLegalEntityName == entity.AccountLegalEntityName &&
                                                                    x.EmployerAccountLegalEntityPublicHashedId == entity.AccountLegalEntityPublicHashedId &&
                                                                    x.EmployerAccountName == entity.AccountName &&
                                                                    x.EmployerAccountPublicHashedId == entity.AccountPublicHashedId));
            }
        }
Ejemplo n.º 3
0
 internal void Assert_SortIsAppliedCorrectlyForEmployerAccountName(SelectEmployerViewModel result, bool reverseSort)
 {
     if (reverseSort)
     {
         Assert.AreEqual("CTestAccountName", result.AccountProviderLegalEntities[0].EmployerAccountName);
         Assert.AreEqual("BTestAccountName", result.AccountProviderLegalEntities[1].EmployerAccountName);
         Assert.AreEqual("ATestAccountName", result.AccountProviderLegalEntities[2].EmployerAccountName);
     }
     else
     {
         Assert.AreEqual("ATestAccountName", result.AccountProviderLegalEntities[0].EmployerAccountName);
         Assert.AreEqual("BTestAccountName", result.AccountProviderLegalEntities[1].EmployerAccountName);
         Assert.AreEqual("CTestAccountName", result.AccountProviderLegalEntities[2].EmployerAccountName);
     }
 }
Ejemplo n.º 4
0
        public async Task ThenIShouldGetBackABadRequestIfACompanyCannotBeFound()
        {
            //Assign
            var request = new SelectEmployerViewModel
            {
                EmployerRef = "251643"
            };

            _mediator.Setup(x => x.SendAsync(It.IsAny <GetEmployerInformationRequest>())).ReturnsAsync(null);

            //Act
            var response = await _employerAccountOrchestrator.GetCompanyDetails(request);

            //Assert
            Assert.AreEqual(HttpStatusCode.BadRequest, response.Status);
            _mediator.Verify(x => x.SendAsync(It.Is <GetEmployerInformationRequest>(info => info.Id.Equals(request.EmployerRef))));
        }
Ejemplo n.º 5
0
        public SelectEmployerFixture()
        {
            _request = new SelectEmployerRequest {
                ProviderId = 1, ApprenticeshipId = 1
            };
            _modelMapperMock = new Mock <IModelMapper>();
            _viewModel       = new SelectEmployerViewModel
            {
                AccountProviderLegalEntities = new List <AccountProviderLegalEntityViewModel>(),
            };

            _modelMapperMock
            .Setup(x => x.Map <SelectEmployerViewModel>(_request))
            .ReturnsAsync(_viewModel);

            Sut = new ApprenticeController(_modelMapperMock.Object, Mock.Of <ICookieStorageService <IndexRequest> >(), Mock.Of <ICommitmentsApiClient>());
        }
Ejemplo n.º 6
0
        public SelectEmployerFixture()
        {
            _request = new SelectEmployerRequest {
                ProviderId = _providerId
            };
            _modelMapperMock = new Mock <IModelMapper>();
            _viewModel       = new SelectEmployerViewModel
            {
                AccountProviderLegalEntities = new List <AccountProviderLegalEntityViewModel>(),
                BackLink = "Test.com"
            };
            _providerId = 123;

            _modelMapperMock
            .Setup(x => x.Map <SelectEmployerViewModel>(_request))
            .ReturnsAsync(_viewModel);

            Sut = new CohortController(Mock.Of <IMediator>(), _modelMapperMock.Object, Mock.Of <ILinkGenerator>(), Mock.Of <ICommitmentsApiClient>(), Mock.Of <IFeatureTogglesService <ProviderFeatureToggle> >(), Mock.Of <IEncodingService>());
        }
Ejemplo n.º 7
0
 public void Assert_ListOfEmployersIsEmpty(SelectEmployerViewModel result)
 {
     Assert.AreEqual(0, result.AccountProviderLegalEntities.Count());
 }
Ejemplo n.º 8
0
 internal void Assert_FilterIsAppliedCorrectlyForEmployerName(SelectEmployerViewModel result)
 {
     Assert.AreEqual(1, result.AccountProviderLegalEntities.Count);
     Assert.AreEqual("ATestAccountLegalEntityName", result.AccountProviderLegalEntities[0].EmployerAccountLegalEntityName);
 }
        public virtual async Task <OrchestratorResponse <OrganisationDetailsViewModel> > GetCompanyDetails(SelectEmployerViewModel viewModel)
        {
            var response = await Mediator.SendAsync(new GetEmployerInformationRequest
            {
                Id = viewModel.EmployerRef
            });

            if (response == null)
            {
                Logger.Warn("No response from SelectEmployerViewModel");
                return(new OrchestratorResponse <OrganisationDetailsViewModel>
                {
                    Status = HttpStatusCode.BadRequest,
                    Data = new OrganisationDetailsViewModel()
                });
            }

            Logger.Info($"Returning Data for {viewModel.EmployerRef}");

            return(new OrchestratorResponse <OrganisationDetailsViewModel>
            {
                Data = new OrganisationDetailsViewModel
                {
                    ReferenceNumber = response.CompanyNumber,
                    Name = response.CompanyName,
                    DateOfInception = response.DateOfIncorporation,
                    Address = $"{response.AddressLine1}, {response.AddressLine2}, {response.AddressPostcode}",
                    Status = response.CompanyStatus,
                }
            });
        }