public void Setup() { var fixture = new Fixture(); _validator = new UpdateApprenticeshipValidator(new ApprenticeshipValidator(new StubCurrentDateTime(), Mock.Of <IUlnValidator>(), Mock.Of <IAcademicYearValidator>())); var populatedCommitment = fixture.Build <Domain.Entities.Apprenticeship>().Create(); _exampleCommand = new UpdateApprenticeshipCommand { Caller = new Caller { CallerType = CallerType.Provider, Id = 1L }, CommitmentId = 123L, ApprenticeshipId = 333L, Apprenticeship = populatedCommitment }; }
public async Task ThenTheMediatorIsCalledToCreateApprenticeship() { UpdateApprenticeshipCommand command = new UpdateApprenticeshipCommand(); _mockMediator.Setup(x => x.SendAsync(It.IsAny <UpdateApprenticeshipCommand>())) .ReturnsAsync(new Unit()) .Callback((UpdateApprenticeshipCommand c) => command = c); _mockApprenticeshipMapper.Setup( m => m.Map(It.IsAny <ApiApprenticeship.Apprenticeship>(), CallerType.Provider)) .Returns(_newApprenticeship); await _controller.PutApprenticeship(TestProviderId, TestCommitmentId, TestApprenticeshipId, _newApprenticeshipRequest); command.Caller.CallerType.Should().Be(CallerType.Provider); command.Caller.Id.Should().Be(TestProviderId); command.CommitmentId.Should().Be(TestCommitmentId); command.ApprenticeshipId.Should().Be(TestApprenticeshipId); command.ApprenticeshipId.Should().Be(TestApprenticeshipId); command.Apprenticeship.Should().Be(_newApprenticeship); command.UserName.Should().Be(_newApprenticeshipRequest.LastUpdatedByInfo.Name); }
public void SetUp() { _mockApprenticeshipEvents = new Mock <IApprenticeshipEvents>(); _mockCommitmentRespository = new Mock <ICommitmentRepository>(); _mockApprenticeshipRepository = new Mock <IApprenticeshipRepository>(); _mockValidator = new Mock <AbstractValidator <UpdateApprenticeshipCommand> >(); _mockHistoryRepository = new Mock <IHistoryRepository>(); _mockApprenticeshipUpdateRules = new Mock <IApprenticeshipUpdateRules>(); _handler = new UpdateApprenticeshipCommandHandler( _mockCommitmentRespository.Object, _mockApprenticeshipRepository.Object, _mockValidator.Object, _mockApprenticeshipUpdateRules.Object, _mockApprenticeshipEvents.Object, Mock.Of <ICommitmentsLogger>(), _mockHistoryRepository.Object); _mockValidator.Setup(x => x.Validate(It.IsAny <UpdateApprenticeshipCommand>())).Returns(new ValidationResult()); var fixture = new Fixture(); var populatedApprenticeship = fixture.Build <Apprenticeship>().Create(); _exampleValidRequest = new UpdateApprenticeshipCommand { Caller = new Caller { CallerType = CallerType.Provider, Id = 111L }, CommitmentId = 123L, ApprenticeshipId = populatedApprenticeship.Id, Apprenticeship = populatedApprenticeship, UserName = "******" }; }