public virtual ApiHandlerPipelineStepResponseModel MapBOToModel(
            BOHandlerPipelineStep boHandlerPipelineStep)
        {
            var model = new ApiHandlerPipelineStepResponseModel();

            model.SetProperties(boHandlerPipelineStep.Id, boHandlerPipelineStep.HandlerId, boHandlerPipelineStep.PipelineStepId);

            return(model);
        }
Exemplo n.º 2
0
        public void MapResponseToRequest()
        {
            var mapper = new ApiHandlerPipelineStepModelMapper();
            var model  = new ApiHandlerPipelineStepResponseModel();

            model.SetProperties(1, 1, 1);
            ApiHandlerPipelineStepRequestModel response = mapper.MapResponseToRequest(model);

            response.HandlerId.Should().Be(1);
            response.PipelineStepId.Should().Be(1);
        }
Exemplo n.º 3
0
        public void MapBOToModel()
        {
            var mapper = new BOLHandlerPipelineStepMapper();
            BOHandlerPipelineStep bo = new BOHandlerPipelineStep();

            bo.SetProperties(1, 1, 1);
            ApiHandlerPipelineStepResponseModel response = mapper.MapBOToModel(bo);

            response.HandlerId.Should().Be(1);
            response.Id.Should().Be(1);
            response.PipelineStepId.Should().Be(1);
        }
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiHandlerPipelineStepResponseModel response = await this.HandlerPipelineStepService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
Exemplo n.º 5
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IHandlerPipelineStepRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <HandlerPipelineStep>(null));
            var service = new HandlerPipelineStepService(mock.LoggerMock.Object,
                                                         mock.RepositoryMock.Object,
                                                         mock.ModelValidatorMockFactory.HandlerPipelineStepModelValidatorMock.Object,
                                                         mock.BOLMapperMockFactory.BOLHandlerPipelineStepMapperMock,
                                                         mock.DALMapperMockFactory.DALHandlerPipelineStepMapperMock);

            ApiHandlerPipelineStepResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Exemplo n.º 6
0
        public async void Create_Errors()
        {
            HandlerPipelineStepControllerMockFacade mock = new HandlerPipelineStepControllerMockFacade();

            var mockResponse = new Mock <CreateResponse <ApiHandlerPipelineStepResponseModel> >(new FluentValidation.Results.ValidationResult());
            var mockRecord   = new ApiHandlerPipelineStepResponseModel();

            mockResponse.SetupGet(x => x.Success).Returns(false);

            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiHandlerPipelineStepRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiHandlerPipelineStepResponseModel> >(mockResponse.Object));
            HandlerPipelineStepController controller = new HandlerPipelineStepController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Create(new ApiHandlerPipelineStepRequestModel());

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiHandlerPipelineStepRequestModel>()));
        }
Exemplo n.º 7
0
        public async void All_Exists()
        {
            HandlerPipelineStepControllerMockFacade mock = new HandlerPipelineStepControllerMockFacade();
            var record  = new ApiHandlerPipelineStepResponseModel();
            var records = new List <ApiHandlerPipelineStepResponseModel>();

            records.Add(record);
            mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            HandlerPipelineStepController controller = new HandlerPipelineStepController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.All(1000, 0);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var items = (response as OkObjectResult).Value as List <ApiHandlerPipelineStepResponseModel>;

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
        public virtual async Task <IActionResult> Patch(int id, [FromBody] JsonPatchDocument <ApiHandlerPipelineStepRequestModel> patch)
        {
            ApiHandlerPipelineStepResponseModel record = await this.HandlerPipelineStepService.Get(id);

            if (record == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                ApiHandlerPipelineStepRequestModel model = await this.PatchModel(id, patch);

                UpdateResponse <ApiHandlerPipelineStepResponseModel> result = await this.HandlerPipelineStepService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
Exemplo n.º 9
0
        public async void TestGet()
        {
            ApiHandlerPipelineStepResponseModel response = await this.Client.HandlerPipelineStepGetAsync(1);

            response.Should().NotBeNull();
        }