Пример #1
0
        public void Arrange()
        {
            _commitmentsApi = new Mock <IEmployerCommitmentApi>();
            _commitmentsApi.Setup(m => m.CreateApprenticeshipUpdate(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <ApprenticeshipUpdateRequest>()))
            .Returns(() => Task.FromResult(new Unit()));

            _validator = new Mock <IValidator <CreateApprenticeshipUpdateCommand> >();
            _validator.Setup(x => x.Validate(It.IsAny <CreateApprenticeshipUpdateCommand>()))
            .Returns(() => new ValidationResult());

            _handler = new CreateApprenticeshipUpdateCommandHandler(_commitmentsApi.Object, _validator.Object);
        }
Пример #2
0
        public void Arrange()
        {
            _validator = new Mock <CreateApprenticeshipUpdateValidator>();
            _apprenticeshipUpdateRepository = new Mock <IApprenticeshipUpdateRepository>();
            _apprenticeshipRepository       = new Mock <IApprenticeshipRepository>();
            _mediator             = new Mock <IMediator>();
            _historyRepository    = new Mock <IHistoryRepository>();
            _commitmentRepository = new Mock <ICommitmentRepository>();
            _mockCurrentDateTime  = new Mock <ICurrentDateTime>();

            _validator.Setup(x => x.Validate(It.IsAny <CreateApprenticeshipUpdateCommand>()))
            .Returns(() => new ValidationResult());

            _apprenticeshipUpdateRepository.Setup(x => x.GetPendingApprenticeshipUpdate(It.IsAny <long>()))
            .ReturnsAsync(null);

            _apprenticeshipUpdateRepository.Setup(x => x.CreateApprenticeshipUpdate(It.IsAny <ApprenticeshipUpdate>(), It.IsAny <Apprenticeship>()))
            .Returns(() => Task.FromResult(new Unit()));

            _existingApprenticeship = new Apprenticeship
            {
                EmployerAccountId = 1,
                ProviderId        = 2,
                ULN          = " 123",
                StartDate    = new DateTime(DateTime.Now.Year + 2, 5, 1),
                EndDate      = new DateTime(DateTime.Now.Year + 2, 9, 1),
                Id           = 3,
                CommitmentId = 974
            };

            _apprenticeshipRepository.Setup(x => x.GetApprenticeship(It.IsAny <long>()))
            .ReturnsAsync(_existingApprenticeship);

            _mediator.Setup(x => x.SendAsync(It.IsAny <GetOverlappingApprenticeshipsRequest>()))
            .ReturnsAsync(new GetOverlappingApprenticeshipsResponse
            {
                Data = new List <ApprenticeshipResult>()
            });

            _commitmentRepository.Setup(x => x.GetCommitmentById(It.IsAny <long>())).ReturnsAsync(new Commitment());
            _mockCurrentDateTime.SetupGet(x => x.Now).Returns(DateTime.UtcNow);

            _handler = new CreateApprenticeshipUpdateCommandHandler(
                _validator.Object,
                _apprenticeshipUpdateRepository.Object,
                Mock.Of <ICommitmentsLogger>(),
                _apprenticeshipRepository.Object,
                _mediator.Object,
                _historyRepository.Object,
                _commitmentRepository.Object,
                _mockCurrentDateTime.Object);
        }