public async Task ThenTheCommitmentsApiIsCalledToSubmitTheUpdate(bool isApproved, ApprenticeshipUpdateStatus expectedStatus)
        {
            //Arrange
            var command = new ReviewApprenticeshipUpdateCommand
            {
                ApprenticeshipId = 1,
                ProviderId       = 2,
                IsApproved       = isApproved,
                UserId           = "tester",
                UserDisplayName  = "Bob",
                UserEmailAddress = "*****@*****.**"
            };

            //Act
            await _handler.Handle(command, new CancellationToken());

            //Assert
            _commitmentsApi.Verify(x => x.PatchApprenticeshipUpdate(
                                       command.ProviderId,
                                       command.ApprenticeshipId,
                                       It.Is <ApprenticeshipUpdateSubmission>(
                                           s =>
                                           s.UpdateStatus == expectedStatus && s.UserId == command.UserId && s.LastUpdatedByInfo.EmailAddress == command.UserEmailAddress &&
                                           s.LastUpdatedByInfo.Name == command.UserDisplayName)),
                                   Times.Once);
        }
        public async Task ThenTheCommandIsValidated()
        {
            //Arrange
            var command = new ReviewApprenticeshipUpdateCommand();

            //Act
            await _handler.Handle(command, new CancellationToken());

            //Assert
            _validator.Verify(x => x.Validate(It.IsAny <ReviewApprenticeshipUpdateCommand>()), Times.Once);
        }
        public void Arrange()
        {
            _validator = new ReviewApprenticeshipUpdateCommandValidator();

            _command = new ReviewApprenticeshipUpdateCommand
            {
                ApprenticeshipId = 1,
                AccountId        = 2,
                IsApproved       = true,
                UserId           = "tester"
            };
        }
        public void ThenIfTheRequestIsNotValidThenAnExceptionIsThrown()
        {
            //Arrange
            _validator.Setup(x => x.Validate(It.IsAny <ReviewApprenticeshipUpdateCommand>()))
            .Returns(() => new ValidationResult
            {
                Errors = { new ValidationFailure("Test", "Error") }
            });

            var command = new ReviewApprenticeshipUpdateCommand();

            //Act & Assert
            Func <Task> act = async() => { await _handler.Handle(command, new CancellationToken()); };

            act.ShouldThrow <ValidationException>();
        }