Пример #1
0
 public CreateCohortController(ICookieStorageService <FlashMessageViewModel> flashMessage,
                               SelectEmployerOrchestrator selectEmployerOrchestrator, CreateCohortOrchestrator createCohortOrchestrator,
                               IFeatureToggleService featureToggleService, ILinkGenerator providerUrlhelper) : base(flashMessage)
 {
     _selectEmployerOrchestrator = selectEmployerOrchestrator;
     _createCohortOrchestrator   = createCohortOrchestrator;
     _featureToggleService       = featureToggleService;
     _providerUrlhelper          = providerUrlhelper;
 }
        public void Arrange()
        {
            _permissionsResponse = new GetProviderRelationshipsWithPermissionQueryResponse
            {
                ProviderRelationships = new List <AccountProviderLegalEntityDto>
                {
                    new AccountProviderLegalEntityDto
                    {
                        AccountPublicHashedId            = _employerAccountPublicHashedId,
                        AccountId                        = _employerAccountId,
                        AccountLegalEntityId             = _employerAccountLegalEntityId,
                        AccountLegalEntityPublicHashedId = _employerAccountLegalEntityPublicHashedId
                    }
                }
            };

            _hashingService = new Mock <IHashingService>();
            _hashingService.Setup(x => x.HashValue(It.Is <long>(l => l == _apiResponse))).Returns("CohortRef");

            _publicHashingService = new Mock <IPublicHashingService>();
            _publicHashingService.Setup(x => x.DecodeValue(It.Is <string>(s => s == _employerAccountPublicHashedId))).Returns(_employerAccountId);
            _publicHashingService.Setup(x => x.DecodeValue(It.Is <string>(s => s == _employerAccountLegalEntityPublicHashedId)))
            .Returns(_employerAccountLegalEntityId);

            _mediator = new Mock <IMediator>();
            _mediator.Setup(x => x.Send(It.IsAny <GetProviderRelationshipsWithPermissionQueryRequest>(),
                                        new CancellationToken()))
            .ReturnsAsync(_permissionsResponse);

            _provider = new GetProviderQueryResponse
            {
                ProvidersView = new ProvidersView
                {
                    CreatedDate = new DateTime(2018, 11, 6),
                    Provider    = new Provider
                    {
                        ProviderName = "Test Provider"
                    }
                }
            };
            _mediator.Setup(x => x.Send(It.IsAny <GetProviderQueryRequest>(), It.IsAny <CancellationToken>())).ReturnsAsync(_provider);

            _legalEntity = new LegalEntity
            {
                Id = 1,
                AccountLegalEntityPublicHashedId = _employerAccountLegalEntityPublicHashedId,
                Code = "code",
                Name = "Test Legal Entity",
                RegisteredAddress = "Test Address",
                Source            = 1
            };
            _mediator.Setup(x =>
                            x.Send(It.IsAny <GetEmployerAccountLegalEntitiesRequest>(), It.IsAny <CancellationToken>())).ReturnsAsync(
                () => new GetEmployerAccountLegalEntitiesResponse
            {
                LegalEntities = new List <LegalEntity>
                {
                    _legalEntity
                }
            });

            _mediator.Setup(x => x.Send(It.IsAny <CreateCommitmentCommand>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new CreateCommitmentCommandResponse {
                CommitmentId = _apiResponse
            });

            _signInUserModel = new SignInUserModel {
                DisplayName = "DisplayName", Email = "*****@*****.**"
            };

            _confirmEmployerViewModel = new ConfirmEmployerViewModel
            {
                EmployerAccountLegalEntityPublicHashedId = _employerAccountLegalEntityPublicHashedId,
                EmployerAccountPublicHashedId            = _employerAccountPublicHashedId
            };

            _orchestrator = new CreateCohortOrchestrator(_mediator.Object,
                                                         _hashingService.Object,
                                                         Mock.Of <IProviderCommitmentsLogger>(),
                                                         _publicHashingService.Object);
        }