public void Setup() { var currentDate = DateTime.Today; _validator = new UpdateApprenticeshipStopDateCommandValidator(); _exampleCommand = new UpdateApprenticeshipStopDateCommand { AccountId = 1L, ApprenticeshipId = 444L, StopDate = DateTime.Today }; }
public override void SetUp() { base.SetUp(); ExampleValidRequest = new UpdateApprenticeshipStopDateCommand { AccountId = 111L, ApprenticeshipId = 444L, StopDate = DateTime.UtcNow.Date, UserName = "******" }; _testCommitment = new Commitment { Id = 123L, EmployerAccountId = ExampleValidRequest.AccountId }; TestApprenticeship = new Apprenticeship { Id = 444L, CommitmentId = 123L, PaymentStatus = PaymentStatus.Withdrawn, StopDate = DateTime.UtcNow.Date.AddMonths(3), StartDate = DateTime.UtcNow.Date.AddMonths(-1) }; MockCurrentDateTime.SetupGet(x => x.Now) .Returns(DateTime.UtcNow); MockApprenticeshipRespository.Setup(x => x.GetApprenticeship(It.Is<long>(y => y == ExampleValidRequest.ApprenticeshipId))) .ReturnsAsync(TestApprenticeship); MockApprenticeshipRespository.Setup(x => x.UpdateApprenticeshipStatus(It.IsAny<long>(), It.IsAny<long>(), It.IsAny<PaymentStatus>())) .Returns(Task.FromResult(new object())); MockDataLockRepository.Setup(x => x.GetDataLocks(ExampleValidRequest.ApprenticeshipId, false)) .ReturnsAsync(new List<DataLockStatus>()); MockCommitmentRespository.Setup(x => x.GetCommitmentById(123L)).ReturnsAsync(_testCommitment); MockApprenticeshipEventsPublisher.Setup(x => x.Publish(It.IsAny<IApprenticeshipEventsList>())) .Returns(Task.FromResult(new Unit())); }
public void Setup() { _newStopDate = DateTime.UtcNow.AddMonths(-2).Date; _validCommand = new UpdateApprenticeshipStopDateCommand { EmployerAccountId = 12L, ApprenticeshipId = 4L, UserId = "externalUserId", NewStopDate = _newStopDate, CommitmentId = 123 }; _testApprenticeship = new Apprenticeship { Id = 4L, FirstName = "TEST", LastName = "APPRENTICE", StartDate = DateTime.UtcNow.AddMonths(-2).Date, StopDate = DateTime.UtcNow.AddMonths(6).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(_testApprenticeship); _mockCurrentDateTime = new Mock <ICurrentDateTime>(); _mockCurrentDateTime.SetupGet(x => x.Now).Returns(DateTime.UtcNow); _providerEmailNotificationService = new Mock <IProviderEmailNotificationService>(); _providerEmailNotificationService.Setup(x => x.SendProviderApprenticeshipStopEditNotification(It.IsAny <Apprenticeship>(), It.IsAny <DateTime>())) .Returns(Task.CompletedTask); _handler = new UpdateApprenticeshipStopDateCommandHandler( _mockCommitmentApi.Object, _mockCurrentDateTime.Object, _validator, _providerEmailNotificationService.Object ); }