Ejemplo n.º 1
0
        public virtual ApiPipelineStepDestinationResponseModel MapBOToModel(
            BOPipelineStepDestination boPipelineStepDestination)
        {
            var model = new ApiPipelineStepDestinationResponseModel();

            model.SetProperties(boPipelineStepDestination.Id, boPipelineStepDestination.DestinationId, boPipelineStepDestination.PipelineStepId);

            return(model);
        }
        public void MapResponseToRequest()
        {
            var mapper = new ApiPipelineStepDestinationModelMapper();
            var model  = new ApiPipelineStepDestinationResponseModel();

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

            response.DestinationId.Should().Be(1);
            response.PipelineStepId.Should().Be(1);
        }
        public void MapBOToModel()
        {
            var mapper = new BOLPipelineStepDestinationMapper();
            BOPipelineStepDestination bo = new BOPipelineStepDestination();

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

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

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

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <PipelineStepDestination>(null));
            var service = new PipelineStepDestinationService(mock.LoggerMock.Object,
                                                             mock.RepositoryMock.Object,
                                                             mock.ModelValidatorMockFactory.PipelineStepDestinationModelValidatorMock.Object,
                                                             mock.BOLMapperMockFactory.BOLPipelineStepDestinationMapperMock,
                                                             mock.DALMapperMockFactory.DALPipelineStepDestinationMapperMock);

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

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

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

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

            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiPipelineStepDestinationRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiPipelineStepDestinationResponseModel> >(mockResponse.Object));
            PipelineStepDestinationController controller = new PipelineStepDestinationController(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 ApiPipelineStepDestinationRequestModel());

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

            records.Add(record);
            mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            PipelineStepDestinationController controller = new PipelineStepDestinationController(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 <ApiPipelineStepDestinationResponseModel>;

            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 <ApiPipelineStepDestinationRequestModel> patch)
        {
            ApiPipelineStepDestinationResponseModel record = await this.PipelineStepDestinationService.Get(id);

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

                UpdateResponse <ApiPipelineStepDestinationResponseModel> result = await this.PipelineStepDestinationService.Update(id, model);

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

            response.Should().NotBeNull();
        }