Exemple #1
0
        public async Task Then_The_Request_Is_Handled_And_Ok_Result_Returned(
            RegisterCheckRequest request,
            RegisterCheckResponse response,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] EmploymentCheckController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <RegisterCheckCommand>(c =>
                                                    c.CorrelationId.Equals(request.CorrelationId) &&
                                                    c.ApprenticeshipAccountId.Equals(request.ApprenticeshipAccountId) &&
                                                    c.ApprenticeshipId.Equals(request.ApprenticeshipId) &&
                                                    c.CheckType.Equals(request.CheckType) &&
                                                    c.MaxDate.Equals(request.MaxDate) &&
                                                    c.MinDate.Equals(request.MinDate) &&
                                                    c.Uln.Equals(request.Uln)
                                                    ),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(response);

            var controllerResult = await controller.RegisterCheck(request) as OkObjectResult;

            Assert.IsNotNull(controllerResult);
            controllerResult.Value.Should().Be(response);
        }
Exemple #2
0
        public async Task Then_If_Validation_Error_Then_Request_Error_Response_Is_Returned(
            RegisterCheckRequest request,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] EmploymentCheckController controller)
        {
            mockMediator.Setup(x => x.Send(It.IsAny <RegisterCheckCommand>(),
                                           CancellationToken.None)).ThrowsAsync(new HttpRequestContentException("error message", HttpStatusCode.BadRequest, "error"));

            var actual = await controller.RegisterCheck(request) as ObjectResult;

            Assert.IsNotNull(actual);
            actual.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
            actual.Value.Should().Be("error");
        }
Exemple #3
0
        public async Task Then_RegisterCheck_is_handled(
            long accountId,
            Api.Models.RegisterCheckRequest request,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] EmploymentCheckController controller)
        {
            var controllerResult = await controller.RegisterCheck(request) as OkObjectResult;

            mockMediator
            .Verify(mediator => mediator.Send(
                        It.Is <RegisterEmploymentCheckCommand>(c =>
                                                               c.CorrelationId.Equals(request.CorrelationId) &&
                                                               c.ApprenticeshipAccountId.Equals(request.ApprenticeshipAccountId) &&
                                                               c.ApprenticeshipId.Equals(request.ApprenticeshipId) &&
                                                               c.CheckType.Equals(request.CheckType) &&
                                                               c.MaxDate.Equals(request.MaxDate) &&
                                                               c.MinDate.Equals(request.MinDate) &&
                                                               c.Uln.Equals(request.Uln)),
                        It.IsAny <CancellationToken>()));

            Assert.IsNotNull(controllerResult);
            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
        }