Exemple #1
0
        public void Setup()
        {
            _validCommand = new UpdateApprenticeshipStatusCommand
            {
                EmployerAccountId = 12L,
                ApprenticeshipId  = 4L,
                UserId            = "externalUserId",
                ChangeType        = ChangeStatusType.Stop,
                DateOfChange      = DateTime.UtcNow.Date
            };

            _testApprenticeship = new Apprenticeship {
                StartDate = DateTime.UtcNow.AddMonths(-2).Date
            };

            _mockCommitmentApi = new Mock <IEmployerCommitmentApi>();
            _mockCommitmentApi.Setup(x => x.GetEmployerCommitment(It.IsAny <long>(), It.IsAny <long>())).ReturnsAsync(new CommitmentView {
                ProviderId = 456L
            });
            _mockMediator = new Mock <IMediator>();

            var apprenticeshipGetResponse = new GetApprenticeshipQueryResponse {
                Apprenticeship = _testApprenticeship
            };

            _mockMediator.Setup(x => x.SendAsync(It.IsAny <GetApprenticeshipQueryRequest>())).ReturnsAsync(apprenticeshipGetResponse);
            _mockCurrentDateTime = new Mock <ICurrentDateTime>();
            _mockCurrentDateTime.SetupGet(x => x.Now).Returns(DateTime.UtcNow);

            _handler = new UpdateApprenticeshipStatusCommandHandler(_mockCommitmentApi.Object, _mockMediator.Object, _mockCurrentDateTime.Object, _validator);
        }
Exemple #2
0
        public void Arrange()
        {
            _validator = new UpdateApprenticeshipStatusCommandValidator();

            _validCommand = new UpdateApprenticeshipStatusCommand
            {
                EmployerAccountId = 1L,
                ApprenticeshipId  = 3L,
                ChangeType        = ChangeStatusType.Stop,
                DateOfChange      = DateTime.UtcNow.Date,
                UserId            = "user123"
            };
        }
Exemple #3
0
        public void Setup()
        {
            _validCommand = new UpdateApprenticeshipStatusCommand
            {
                EmployerAccountId = 12L,
                ApprenticeshipId  = 4L,
                UserId            = "externalUserId",
                ChangeType        = ChangeStatusType.Resume,
                DateOfChange      = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, 1)
            };

            _testApprenticeship = new Apprenticeship {
                StartDate = DateTime.UtcNow.AddMonths(-2).Date, PaymentStatus = PaymentStatus.Paused
            };

            _mockCommitmentApi = new Mock <IEmployerCommitmentApi>();
            _mockCommitmentApi.Setup(x => x.GetEmployerCommitment(It.IsAny <long>(), It.IsAny <long>()))
            .ReturnsAsync(new CommitmentView {
                ProviderId = 456L
            });
            _mockCommitmentApi.Setup(x => x.GetEmployerApprenticeship(It.IsAny <long>(), It.IsAny <long>()))
            .ReturnsAsync(_testApprenticeship);

            _mockCurrentDateTime = new Mock <ICurrentDateTime>();
            _mockCurrentDateTime.SetupGet(x => x.Now).Returns(DateTime.UtcNow);

            _academicYearDateProvider = new Mock <IAcademicYearDateProvider>();
            _academicYearDateProvider.Setup(x => x.CurrentAcademicYearStartDate).Returns(new DateTime(2016, 8, 1));

            _academicYearValidator = new Mock <IAcademicYearValidator>();

            _providerEmailNotificationService = new Mock <IProviderEmailNotificationService>();
            _providerEmailNotificationService.Setup(x =>
                                                    x.SendProviderApprenticeshipResumeNotification(It.IsAny <Apprenticeship>(),
                                                                                                   It.IsAny <DateTime>()))
            .Returns(Task.CompletedTask);

            _handler = new UpdateApprenticeshipStatusCommandHandler(
                _mockCommitmentApi.Object,
                _mockCurrentDateTime.Object,
                _validator,
                _providerEmailNotificationService.Object
                );
        }
        public void Setup()
        {
            _validCommand = new UpdateApprenticeshipStatusCommand
            {
                EmployerAccountId = 12L,
                ApprenticeshipId  = 4L,
                UserId            = "externalUserId",
                ChangeType        = ChangeStatusType.Stop,
                DateOfChange      = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, 1),
                UserEmailAddress  = "*****@*****.**",
                UserDisplayName   = "Bob"
            };

            var apprenticeshipFromApi = new Apprenticeship {
                StartDate = DateTime.UtcNow.AddMonths(-2).Date
            };

            _mockCommitmentApi = new Mock <IEmployerCommitmentApi>();
            _mockCommitmentApi.Setup(x => x.GetEmployerCommitment(It.IsAny <long>(), It.IsAny <long>()))
            .ReturnsAsync(new CommitmentView {
                ProviderId = 456L
            });
            _mockCommitmentApi.Setup(x => x.GetEmployerApprenticeship(It.IsAny <long>(), It.IsAny <long>()))
            .ReturnsAsync(apprenticeshipFromApi);

            _mockCurrentDateTime = new Mock <ICurrentDateTime>();
            _mockCurrentDateTime.SetupGet(x => x.Now).Returns(DateTime.UtcNow);

            new Mock <IAcademicYearDateProvider>();
            new Mock <IAcademicYearValidator>();

            _providerEmailNotificationService = new Mock <IProviderEmailNotificationService>();
            _providerEmailNotificationService.Setup(x =>
                                                    x.SendProviderApprenticeshipStopNotification(It.IsAny <Apprenticeship>(), It.IsAny <DateTime>())).Returns(Task.CompletedTask);

            _handler = new UpdateApprenticeshipStatusCommandHandler(
                _mockCommitmentApi.Object,
                _mockCurrentDateTime.Object,
                _validator,
                _providerEmailNotificationService.Object
                );
        }