Ejemplo n.º 1
0
        public async Task ThenAppropriateCommandIsSentToMediator(ApprenticeshipUpdateStatus updateStatus, Type expectedCommand)
        {
            //Arrange
            var submission = new ApprenticeshipUpdateSubmission
            {
                UpdateStatus      = updateStatus,
                LastUpdatedByInfo = new LastUpdateInfo(),
                UserId            = "TEST"
            };

            //Act
            await Orchestrator.PatchApprenticeshipUpdate(1, 1, submission);

            //Assert
            MockMediator.Verify(x => x.SendAsync(It.Is <IAsyncRequest>(o => o.GetType() == expectedCommand)), Times.Once);
        }
        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);
        }
Ejemplo n.º 3
0
        public async Task WhenGetUpdateRequestReceived_ThenShouldPassApprenticeIdAndStatusToQuery(ApprenticeshipUpdateStatus status)
        {
            await _fixture.SetStatus(status).GetApprenticeshipUpdates();

            _fixture.VerifyApprenticeshipIdAndStatusPassedToQuery();
        }
Ejemplo n.º 4
0
        private async Task UpdateApprenticeshipUpdate(IDbConnection connection, IDbTransaction trans, long apprenticeshipUpdateId, string userId, ApprenticeshipUpdateStatus updateStatus)
        {
            var parameters = new DynamicParameters();

            parameters.Add("@id", apprenticeshipUpdateId, DbType.Int64);
            parameters.Add("@status", updateStatus, DbType.Int16);

            await connection.ExecuteAsync(
                sql :
                "UPDATE [dbo].[ApprenticeshipUpdate] SET Status = @status " +
                "WHERE Id = @id;",
                param : parameters,
                commandType : CommandType.Text,
                transaction : trans);
        }
Ejemplo n.º 5
0
        private async Task UpdateApprenticeshipUpdate(IDbConnection connection, IDbTransaction trans, long apprenticeshipUpdateId, ApprenticeshipUpdateStatus updateStatus)
        {
            var parameters = new DynamicParameters();

            parameters.Add("@id", apprenticeshipUpdateId, DbType.Int64);
            parameters.Add("@status", updateStatus, DbType.Int16);

            await connection.ExecuteAsync(
                sql : "[UpdateApprenticeshipUpdateStatus]",
                param : parameters,
                commandType : CommandType.StoredProcedure,
                transaction : trans);
        }
        public async Task GetApprenticeshipUpdates_WithStatus_VerifyUrlAndData(int apprenticeshipId, ApprenticeshipUpdateStatus status)
        {
            var request = new GetApprenticeshipUpdatesRequest {
                Status = status
            };
            await _fixture.CommitmentsApiClient.GetApprenticeshipUpdates(apprenticeshipId, request);

            _fixture.MockRestHttpClient.Verify(x => x.Get <GetApprenticeshipUpdatesResponse>($"api/apprenticeships/{apprenticeshipId}/updates?status={status}", null, CancellationToken.None));
        }