Exemple #1
0
        public void Setup()
        {
            _mockFacetMapper = new Mock <FacetMapper>(Mock.Of <ICurrentDateTime>());

            _mockMediator             = new Mock <IMediator>();
            _mockApprenticeshipMapper = new Mock <IApprenticeshipMapper>();
            _providerOrchestrator     = new ProviderOrchestrator(
                _mockMediator.Object,
                Mock.Of <ICommitmentsLogger>(),
                _mockFacetMapper.Object,
                new ApprenticeshipFilterService(_mockFacetMapper.Object),
                _mockApprenticeshipMapper.Object,
                Mock.Of <ICommitmentMapper>());

            _apprenticeshipsOrchestrator = new ApprenticeshipsOrchestrator(_mockMediator.Object, Mock.Of <IDataLockMapper>(), Mock.Of <IApprenticeshipMapper>(), Mock.Of <ICommitmentsLogger>());
            _controller = new ProviderController(_providerOrchestrator, _apprenticeshipsOrchestrator);

            _newApprenticeship = new Domain.Entities.Apprenticeship
            {
                CommitmentId = TestCommitmentId,
                Id           = TestApprenticeshipId
            };

            _newApprenticeshipRequest = new ApiApprenticeship.ApprenticeshipRequest
            {
                Apprenticeship    = new ApiApprenticeship.Apprenticeship(),
                LastUpdatedByInfo = new LastUpdateInfo {
                    EmailAddress = "*****@*****.**", Name = "Bob"
                }
            };
        }
        public async Task ThenTheMediatorIsCalledToCreateApprenticeship()
        {
            var newApprenticeship = new Apprenticeship.ApprenticeshipRequest
            {
                Apprenticeship = new Apprenticeship.Apprenticeship(),
                LastUpdatedByInfo = new LastUpdateInfo { EmailAddress = "*****@*****.**", Name = "Bob" }
            };

            var expectedApprenticeship = new Domain.Entities.Apprenticeship();

            _apprenticeshipMapper.Setup(m => m.Map(newApprenticeship.Apprenticeship, CallerType.Employer))
                .Returns(expectedApprenticeship);

            var result = await _controller.CreateApprenticeship(TestAccountId, TestCommitmentId, newApprenticeship);
            _mockMediator.Verify(
                x =>
                    x.SendAsync(
                        It.Is<CreateApprenticeshipCommand>(
                            a =>
                                a.Caller.CallerType == CallerType.Employer && a.Caller.Id == TestAccountId && a.CommitmentId == TestCommitmentId && a.Apprenticeship == expectedApprenticeship &&
                                a.UserName == newApprenticeship.LastUpdatedByInfo.Name)));
        }
Exemple #3
0
        public async Task PutApprenticeship(long accountId, long commitmentId, long apprenticeshipId, Apprenticeship.ApprenticeshipRequest apprenticeshipRequest)
        {
            _logger.Trace($"Updating apprenticeship {apprenticeshipId} in commitment {commitmentId} for employer account {accountId}", accountId: accountId, commitmentId: commitmentId, apprenticeshipId: apprenticeshipId);

            apprenticeshipRequest.Apprenticeship.CommitmentId = commitmentId;

            await _mediator.SendAsync(new UpdateApprenticeshipCommand
            {
                Caller = new Caller
                {
                    CallerType = CallerType.Employer,
                    Id         = accountId
                },
                CommitmentId     = commitmentId,
                ApprenticeshipId = apprenticeshipId,
                Apprenticeship   = _apprenticeshipMapper.Map(apprenticeshipRequest.Apprenticeship, CallerType.Employer),
                UserId           = apprenticeshipRequest.UserId,
                UserName         = apprenticeshipRequest.LastUpdatedByInfo?.Name
            });

            _logger.Info($"Updated apprenticeship {apprenticeshipId} in commitment {commitmentId} for employer account {accountId}", accountId: accountId, commitmentId: commitmentId, apprenticeshipId: apprenticeshipId);
        }