Exemplo n.º 1
0
        public void Setup()
        {
            _validCommand = new SubmitCommitmentCommand {
                EmployerAccountId = 12L, CommitmentId = 2L, UserDisplayName = "Test User", UserEmailAddress = "*****@*****.**", UserId = "externalUserId"
            };
            _repositoryCommitment = new CommitmentView
            {
                ProviderId        = 456L,
                EmployerAccountId = 12L,
                AgreementStatus   = AgreementStatus.NotAgreed,
                Reference         = CohortReference
            };

            _mockCommitmentApi = new Mock <IEmployerCommitmentApi>();
            _mockCommitmentApi.Setup(x => x.GetEmployerCommitment(It.IsAny <long>(), It.IsAny <long>()))
            .ReturnsAsync(_repositoryCommitment);

            var config = new EmployerCommitmentsServiceConfiguration
            {
                CommitmentNotification = new CommitmentNotificationConfiguration {
                    SendEmail = true
                }
            };

            _mockEmailService = new Mock <IProviderEmailService>();

            _handler = new SubmitCommitmentCommandHandler(_mockCommitmentApi.Object, config, Mock.Of <ILog>(), _mockEmailService.Object);
        }
        public void Arrange()
        {
            _configuration = new EmployerCommitmentsServiceConfiguration
            {
                CommitmentNotification = new CommitmentNotificationConfiguration
                {
                    SendEmail = true
                }
            };

            _providerEmailService = new Mock <IProviderEmailService>();
            _providerEmailService.Setup(x =>
                                        x.SendEmailToAllProviderRecipients(It.IsAny <long>(), It.IsAny <string>(), It.IsAny <EmailMessage>()))
            .Callback <long, string, EmailMessage>((l, s, m) => _sentEmailMessage = m)
            .Returns(Task.CompletedTask);

            _providerEmailNotificationService =
                new ProviderEmailNotificationService(_providerEmailService.Object, Mock.Of <ILog>(), Mock.Of <IHashingService>(), _configuration);

            _exampleCommitmentView = new CommitmentView
            {
                ProviderId             = 1,
                ProviderLastUpdateInfo = new LastUpdateInfo {
                    EmailAddress = "LastUpdateEmail"
                },
                LegalEntityName = "Legal Entity Name",
                Reference       = "Cohort Reference"
            };

            _act = async() =>
                   await _providerEmailNotificationService.SendProviderTransferRejectedCommitmentEditNotification(
                _exampleCommitmentView);
        }
 public IdamsEmailServiceWrapper(
     ILog logger,
     EmployerCommitmentsServiceConfiguration configuration,
     IHttpClientWrapper httpClient,
     [RequiredPolicy(IdamsExecutionPolicy.Name)] ExecutionPolicy executionPolicy)
 {
     _logger            = logger;
     _configuration     = configuration.CommitmentNotification;
     _httpClientWrapper = httpClient;
     _executionPolicy   = executionPolicy;
 }
        public SubmitCommitmentCommandHandler(
            IEmployerCommitmentApi commitmentApi,
            EmployerCommitmentsServiceConfiguration configuration,
            ILog logger, IProviderEmailService providerEmailService)
        {
            _commitmentApi        = commitmentApi;
            _configuration        = configuration;
            _logger               = logger;
            _providerEmailService = providerEmailService;

            _validator = new SubmitCommitmentCommandValidator();
        }
Exemplo n.º 5
0
 public TransferApprovalCommandHandler(
     IEmployerCommitmentApi commitmentsApi,
     EmployerCommitmentsServiceConfiguration configuration,
     ILog logger,
     IProviderEmailNotificationService providerEmailNotificationService,
     IEmployerEmailNotificationService employerEmailNotificationService)
 {
     _commitmentsService = commitmentsApi;
     _configuration      = configuration;
     _logger             = logger;
     _providerEmailNotificationService = providerEmailNotificationService;
     _employerEmailNotificationService = employerEmailNotificationService;
 }
Exemplo n.º 6
0
        public void SetUp()
        {
            var config = new EmployerCommitmentsServiceConfiguration
            {
                CommitmentNotification = new CommitmentNotificationConfiguration
                {
                    IdamsListUsersUrl =
                        "https://url.to/users/ukprn={0}",
                    ClientToken = "AbbA-Rules-4.Ever"
                }
            };

            _mockHttpClientWrapper = new Mock <IHttpClientWrapper>();
            _sut = new IdamsEmailServiceWrapper(Mock.Of <ILog>(), config, _mockHttpClientWrapper.Object, new NoopExecutionPolicy());
        }
        public void Arrange()
        {
            _configuration = new EmployerCommitmentsServiceConfiguration
            {
                CommitmentNotification = new CommitmentNotificationConfiguration
                {
                    SendEmail = true
                }
            };

            _providerEmailService = new Mock <IProviderEmailService>();
            _providerEmailService.Setup(x =>
                                        x.SendEmailToAllProviderRecipients(It.IsAny <long>(), It.IsAny <string>(), It.IsAny <EmailMessage>()))
            .Callback <long, string, EmailMessage>((l, s, m) => _sentEmailMessage = m)
            .Returns(Task.CompletedTask);

            _hashingService = new Mock <IHashingService>();
            _hashingService.Setup(x => x.HashValue(It.IsAny <long>())).Returns("HASH");

            _providerEmailNotificationService =
                new ProviderEmailNotificationService(_providerEmailService.Object, Mock.Of <ILog>(), _hashingService.Object, _configuration);

            var payload = new Apprenticeship
            {
                ProviderId      = 123L,
                LegalEntityName = "Legal Entity Name",
                ULN             = "1234567890",
                FirstName       = "John",
                LastName        = "Smith",
                PaymentStatus   = PaymentStatus.Withdrawn,
                StopDate        = new DateTime(2018, 05, 01)
            };

            //Keep a copy of the payload to assert against, to guard against handler modifications
            _exampleApprenticeship =
                JsonConvert.DeserializeObject <Apprenticeship>(JsonConvert.SerializeObject(payload));

            _exampleNewStopDate = new DateTime(2018, 04, 01);

            _act = async() =>
                   await _providerEmailNotificationService.SendProviderApprenticeshipStopEditNotification(
                payload, _exampleNewStopDate);
        }
        public void Setup()
        {
            _command = new TransferApprovalCommand
            {
                CommitmentId     = 876,
                TransferSenderId = 676,
                TransferStatus   = TransferApprovalStatus.Rejected
            };

            _repositoryCommitment = new CommitmentView
            {
                TransferSender = new TransferSender
                {
                    Id = _command.TransferSenderId,
                    TransferApprovalStatus = TransferApprovalStatus.Pending
                }
            };

            _mockCommitmentApi = new Mock <IEmployerCommitmentApi>();
            _mockCommitmentApi.Setup(x => x.GetTransferSenderCommitment(It.IsAny <long>(), It.IsAny <long>()))
            .ReturnsAsync(_repositoryCommitment);

            var config = new EmployerCommitmentsServiceConfiguration
            {
                CommitmentNotification = new CommitmentNotificationConfiguration {
                    SendEmail = true
                }
            };

            _providerEmailNotificationService = new Mock <IProviderEmailNotificationService>();
            _providerEmailNotificationService
            .Setup(x => x.SendSenderApprovedOrRejectedCommitmentNotification(It.IsAny <CommitmentView>(), It.IsAny <TransferApprovalStatus>()))
            .Returns(() => Task.CompletedTask);

            _employerEmailNotificationService = new Mock <IEmployerEmailNotificationService>();
            _employerEmailNotificationService
            .Setup(x => x.SendSenderApprovedOrRejectedCommitmentNotification(It.IsAny <CommitmentView>(), It.IsAny <TransferApprovalStatus>()))
            .Returns(() => Task.CompletedTask);

            _sut = new TransferApprovalCommandHandler(_mockCommitmentApi.Object, config,
                                                      Mock.Of <ILog>(), _providerEmailNotificationService.Object, _employerEmailNotificationService.Object);
        }
        public void Arrange()
        {
            _configuration = new EmployerCommitmentsServiceConfiguration
            {
                CommitmentNotification = new CommitmentNotificationConfiguration
                {
                    SendEmail = true
                }
            };

            _providerEmailService = new Mock <IProviderEmailService>();
            _providerEmailService.Setup(x =>
                                        x.SendEmailToAllProviderRecipients(It.IsAny <long>(), It.IsAny <string>(), It.IsAny <EmailMessage>()))
            .Callback <long, string, EmailMessage>((l, s, m) => _sentEmailMessage = m)
            .Returns(Task.CompletedTask);

            _providerEmailNotificationService =
                new ProviderEmailNotificationService(_providerEmailService.Object, Mock.Of <ILog>(), Mock.Of <IHashingService>(), _configuration);

            _exampleCommitmentView = new CommitmentView
            {
                Reference              = CohortReference,
                ProviderId             = ProviderId,
                ProviderLastUpdateInfo = new LastUpdateInfo {
                    EmailAddress = ProviderLastUpdatedByEmail
                }
            };

            _transferApprovalStatus = TransferApprovalStatus.Approved;

            _tokens = new Dictionary <string, string>
            {
                { "cohort_reference", CohortReference },
                { "ukprn", ProviderId.ToString() }
            };

            _act = async() =>
                   await _providerEmailNotificationService.SendSenderApprovedOrRejectedCommitmentNotification(_exampleCommitmentView, _transferApprovalStatus);
        }
 private void ConfigureHashingService(EmployerCommitmentsServiceConfiguration config)
 {
     For <IHashingService>().Use(x => new HashingService.HashingService(config.AllowedHashstringCharacters, config.Hashstring));
     For <IPublicHashingService>().Use(x => new PublicHashingService.PublicHashingService(config.PublicAllowedHashstringCharacters, config.PublicHashstring));
 }
 private void RegisterPasAccountApi(EmployerCommitmentsServiceConfiguration config)
 {
     For <PAS.Account.Api.Client.IPasAccountApiConfiguration>().Use(config.ProviderAccountUserApi);
     For <PAS.Account.Api.Client.IPasAccountApiClient>().Use <PAS.Account.Api.Client.PasAccountApiClient>();
 }
Exemplo n.º 12
0
 public IdentityServerConfigurationFactory(EmployerCommitmentsServiceConfiguration configuration)
 {
     _configuration = configuration;
 }
 public ProviderEmailNotificationService(IProviderEmailService providerEmailService, ILog logger, IHashingService hashingService, EmployerCommitmentsServiceConfiguration configuration)
     : base(logger, hashingService)
 {
     _providerEmailService = providerEmailService;
     _configuration        = configuration;
 }
 public ServiceController(IOwinWrapper owinWrapper, IMultiVariantTestingService multiVariantTestingService, ICookieStorageService <FlashMessageViewModel> flashMessage, EmployerCommitmentsServiceConfiguration configuration)
     : base(owinWrapper, multiVariantTestingService, flashMessage)
 {
     _configuration = configuration;
 }
 public OwinWrapper(EmployerCommitmentsServiceConfiguration configuration)
 {
     _configuration = configuration;
     _owinContext   = HttpContext.Current.GetOwinContext();
 }