public void Setup() { _handler = new CreateApprenticeshipCommandHandler(Mock.Of <IEmployerCommitmentApi>()); _validCommand = new CreateApprenticeshipCommand { AccountId = 123, Apprenticeship = new Apprenticeship() }; }
public void CommitmentIdMustBeGreaterThanZeroElseExceptionThrown(long commitmentId) { var command = new CreateApprenticeshipCommand { AccountId = 123, Apprenticeship = new Apprenticeship { CommitmentId = commitmentId } }; Assert.ThrowsAsync <InvalidRequestException>(() => _handler.Handle(command)); }
public void ThenValidationErrorsShouldThrowAnExceptionWhenUserIdMissing() { var command = new CreateApprenticeshipCommand { AccountId = 123, Apprenticeship = new Apprenticeship { CommitmentId = 321 }, UserId = string.Empty }; Assert.ThrowsAsync <InvalidRequestException>(async() => await _handler.Handle(command)); }
public void OnlyValidCommitmentIdAndAccountIdNeedsToBePopulated() { var command = new CreateApprenticeshipCommand { AccountId = 123, Apprenticeship = new Apprenticeship { CommitmentId = 321 }, UserId = "externalUserId" }; Assert.DoesNotThrowAsync(() => _handler.Handle(command)); }
public void SetUp() { _mockApprenticeshipEvents = new Mock <IApprenticeshipEvents>(); _mockCommitmentRespository = new Mock <ICommitmentRepository>(); _mockApprenticeshipRepository = new Mock <IApprenticeshipRepository>(); _mockHistoryRepository = new Mock <IHistoryRepository>(); _mockUlnValidator = new Mock <IUlnValidator>(); _mockAcademicYearValidator = new Mock <IAcademicYearValidator>(); var validator = new CreateApprenticeshipValidator(new ApprenticeshipValidator(new StubCurrentDateTime(), _mockUlnValidator.Object, _mockAcademicYearValidator.Object)); _handler = new CreateApprenticeshipCommandHandler( _mockCommitmentRespository.Object, _mockApprenticeshipRepository.Object, validator, _mockApprenticeshipEvents.Object, Mock.Of <ICommitmentsLogger>(), _mockHistoryRepository.Object); var fixture = new Fixture(); var populatedApprenticeship = fixture.Build <Apprenticeship>() .With(x => x.ULN, "1234567890") .With(x => x.ULN, ApprenticeshipTestDataHelper.CreateValidULN()) .With(x => x.NINumber, ApprenticeshipTestDataHelper.CreateValidNino()) .With(x => x.FirstName, "First name") .With(x => x.FirstName, "Last name") .With(x => x.ProviderRef, "Provider ref") .With(x => x.EmployerRef, null) .With(x => x.StartDate, DateTime.Now.AddYears(5)) .With(x => x.EndDate, DateTime.Now.AddYears(7)) .With(x => x.DateOfBirth, DateTime.Now.AddYears(-16)) .With(x => x.TrainingCode, string.Empty) .With(x => x.TrainingName, string.Empty) .Create(); _mockApprenticeshipRepository.Setup(m => m.GetApprenticeship(It.IsAny <long>())) .ReturnsAsync(new Domain.Entities.Apprenticeship { Id = expectedApprenticeshipId, ProviderId = _providerId, EmployerAccountId = _employerAccountId }); _exampleValidRequest = new CreateApprenticeshipCommand { Caller = new Caller { CallerType = CallerType.Provider, Id = 111L }, CommitmentId = 123L, Apprenticeship = populatedApprenticeship, UserId = "ABBA123" }; }
public void Setup() { _commitmentApi = new Mock <IEmployerCommitmentApi>(); _handler = new CreateApprenticeshipCommandHandler(_commitmentApi.Object); _validCommand = new CreateApprenticeshipCommand { AccountId = 123, Apprenticeship = new Apprenticeship { CommitmentId = 5634 }, UserId = "ABC123", UserDisplayName = "Bob", UserEmailAddress = "*****@*****.**" }; }
public void Setup() { _validator = new CreateApprenticeshipValidator(new ApprenticeshipValidator(new StubCurrentDateTime(), Mock.Of <IUlnValidator>(), Mock.Of <IAcademicYearValidator>())); var exampleValidApprenticeship = new Domain.Entities.Apprenticeship { FirstName = "Bob", LastName = "Smith", NINumber = ApprenticeshipTestDataHelper.CreateValidNino(), ULN = ApprenticeshipTestDataHelper.CreateValidULN(), ProviderRef = "Provider ref", EmployerRef = null, StartDate = DateTime.Now.AddYears(5), EndDate = DateTime.Now.AddYears(7) }; _exampleCommand = new CreateApprenticeshipCommand { Caller = new Caller { CallerType = CallerType.Provider, Id = 1 }, CommitmentId = 123L, Apprenticeship = exampleValidApprenticeship }; }
public async Task <IActionResult> AddApprenticeship(CreateApprenticeshipCommand request) { await _mediator.Send(request); return(Accepted()); }
public async Task WhenTheFollowingApprenticeshipIsPosted(Table table) { _request = table.CreateInstance <CreateApprenticeshipCommand>(); await _context.OuterApiClient.Post("apprenticeships", _request); }