Esempio n. 1
0
        public virtual ApiPipelineStepStatusResponseModel MapBOToModel(
            BOPipelineStepStatus boPipelineStepStatus)
        {
            var model = new ApiPipelineStepStatusResponseModel();

            model.SetProperties(boPipelineStepStatus.Id, boPipelineStepStatus.Name);

            return(model);
        }
Esempio n. 2
0
        public void MapResponseToRequest()
        {
            var mapper = new ApiPipelineStepStatusModelMapper();
            var model  = new ApiPipelineStepStatusResponseModel();

            model.SetProperties(1, "A");
            ApiPipelineStepStatusRequestModel response = mapper.MapResponseToRequest(model);

            response.Name.Should().Be("A");
        }
        public void MapBOToModel()
        {
            var mapper = new BOLPipelineStepStatusMapper();
            BOPipelineStepStatus bo = new BOPipelineStepStatus();

            bo.SetProperties(1, "A");
            ApiPipelineStepStatusResponseModel response = mapper.MapBOToModel(bo);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiPipelineStepStatusResponseModel response = await this.PipelineStepStatusService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IPipelineStepStatusRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <PipelineStepStatus>(null));
            var service = new PipelineStepStatusService(mock.LoggerMock.Object,
                                                        mock.RepositoryMock.Object,
                                                        mock.ModelValidatorMockFactory.PipelineStepStatusModelValidatorMock.Object,
                                                        mock.BOLMapperMockFactory.BOLPipelineStepStatusMapperMock,
                                                        mock.DALMapperMockFactory.DALPipelineStepStatusMapperMock,
                                                        mock.BOLMapperMockFactory.BOLPipelineStepMapperMock,
                                                        mock.DALMapperMockFactory.DALPipelineStepMapperMock);

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

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

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

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

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

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

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

            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 <ApiPipelineStepStatusRequestModel> patch)
        {
            ApiPipelineStepStatusResponseModel record = await this.PipelineStepStatusService.Get(id);

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

                UpdateResponse <ApiPipelineStepStatusResponseModel> result = await this.PipelineStepStatusService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
        public async void TestGet()
        {
            ApiPipelineStepStatusResponseModel response = await this.Client.PipelineStepStatusGetAsync(1);

            response.Should().NotBeNull();
        }