Exemple #1
0
        public void And_ApiDoesNotReturnSuccess_Then_ThrowApiResponseException(
            HttpStatusCode statusCode,
            CreateApprenticeFeedbackCommand command,
            string errorContent)
        {
            var response = new ApiResponse <object>(null, statusCode, errorContent);

            _mockApiClient.Setup(c => c.PostWithResponseCode <object>(It.IsAny <CreateApprenticeFeedbackRequest>()))
            .ReturnsAsync(response);

            Func <Task> act = async() => await _handler.Handle(command, CancellationToken.None);

            act.Should().ThrowAsync <ApiResponseException>();
        }
Exemple #2
0
        public async Task Then_PostRequestIsSent(CreateApprenticeFeedbackCommand command, string errorContent)
        {
            var             response         = new ApiResponse <CreateApprenticeFeedbackResponse>(new CreateApprenticeFeedbackResponse(), HttpStatusCode.Created, errorContent);
            IPostApiRequest submittedRequest = null;

            _mockApiClient.Setup(c => c.PostWithResponseCode <CreateApprenticeFeedbackResponse>(It.IsAny <CreateApprenticeFeedbackRequest>()))
            .Callback <IPostApiRequest>(x => submittedRequest = x)
            .ReturnsAsync(response);

            await _handler.Handle(command, CancellationToken.None);

            _mockApiClient.Verify(c => c.PostWithResponseCode <object>(It.IsAny <IPostApiRequest>()));
            (submittedRequest.Data).Should().BeEquivalentTo(new
            {
                command.ApprenticeFeedbackTargetId,
                command.OverallRating,
                command.AllowContact,
                command.FeedbackAttributes
            });
        }
Exemple #3
0
        public async Task And_CommandIsProcessedSuccessfully_Then_ReturnCreated(CreateApprenticeFeedbackCommand request)
        {
            var result = await _controller.CreateFeedbackTarget(request);

            result.Should().NotBeNull();
        }
 public async Task <ActionResult <CreateApprenticeFeedbackResponse> > CreateFeedbackTarget(CreateApprenticeFeedbackCommand request)
 => await _mediator.Send(request);