public async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            var createModel = new ApiPipelineStepStatuRequestModel();

            createModel.SetProperties("B");
            CreateResponse <ApiPipelineStepStatuResponseModel> createResult = await client.PipelineStepStatuCreateAsync(createModel);

            createResult.Success.Should().BeTrue();

            ApiPipelineStepStatuResponseModel getResponse = await client.PipelineStepStatuGetAsync(2);

            getResponse.Should().NotBeNull();

            ActionResponse deleteResult = await client.PipelineStepStatuDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();

            ApiPipelineStepStatuResponseModel verifyResponse = await client.PipelineStepStatuGetAsync(2);

            verifyResponse.Should().BeNull();
        }
        public void MapResponseToRequest()
        {
            var mapper = new ApiPipelineStepStatuModelMapper();
            var model  = new ApiPipelineStepStatuResponseModel();

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

            response.Name.Should().Be("A");
        }
        private async Task <ApiPipelineStepStatuResponseModel> CreateRecord(ApiClient client)
        {
            var model = new ApiPipelineStepStatuRequestModel();

            model.SetProperties("B");
            CreateResponse <ApiPipelineStepStatuResponseModel> result = await client.PipelineStepStatuCreateAsync(model);

            result.Success.Should().BeTrue();
            return(result.Record);
        }
Example #4
0
        public void MapModelToBO()
        {
            var mapper = new BOLPipelineStepStatuMapper();
            ApiPipelineStepStatuRequestModel model = new ApiPipelineStepStatuRequestModel();

            model.SetProperties("A");
            BOPipelineStepStatu response = mapper.MapModelToBO(1, model);

            response.Name.Should().Be("A");
        }
        public virtual BOPipelineStepStatu MapModelToBO(
            int id,
            ApiPipelineStepStatuRequestModel model
            )
        {
            BOPipelineStepStatu boPipelineStepStatu = new BOPipelineStepStatu();

            boPipelineStepStatu.SetProperties(
                id,
                model.Name);
            return(boPipelineStepStatu);
        }
Example #6
0
        public virtual async Task <IActionResult> Create([FromBody] ApiPipelineStepStatuRequestModel model)
        {
            CreateResponse <ApiPipelineStepStatuResponseModel> result = await this.PipelineStepStatuService.Create(model);

            if (result.Success)
            {
                return(this.Created($"{this.Settings.ExternalBaseUrl}/api/PipelineStepStatus/{result.Record.Id}", result));
            }
            else
            {
                return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
            }
        }
        public void CreatePatch()
        {
            var mapper = new ApiPipelineStepStatuModelMapper();
            var model  = new ApiPipelineStepStatuRequestModel();

            model.SetProperties("A");

            JsonPatchDocument <ApiPipelineStepStatuRequestModel> patch = mapper.CreatePatch(model);
            var response = new ApiPipelineStepStatuRequestModel();

            patch.ApplyTo(response);
            response.Name.Should().Be("A");
        }
Example #8
0
        private async Task <ApiPipelineStepStatuRequestModel> PatchModel(int id, JsonPatchDocument <ApiPipelineStepStatuRequestModel> patch)
        {
            var record = await this.PipelineStepStatuService.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                ApiPipelineStepStatuRequestModel request = this.PipelineStepStatuModelMapper.MapResponseToRequest(record);
                patch.ApplyTo(request);
                return(request);
            }
        }
        public virtual async Task <CreateResponse <ApiPipelineStepStatuResponseModel> > Create(
            ApiPipelineStepStatuRequestModel model)
        {
            CreateResponse <ApiPipelineStepStatuResponseModel> response = new CreateResponse <ApiPipelineStepStatuResponseModel>(await this.PipelineStepStatuModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                var bo     = this.BolPipelineStepStatuMapper.MapModelToBO(default(int), model);
                var record = await this.PipelineStepStatuRepository.Create(this.DalPipelineStepStatuMapper.MapBOToEF(bo));

                response.SetRecord(this.BolPipelineStepStatuMapper.MapBOToModel(this.DalPipelineStepStatuMapper.MapEFToBO(record)));
            }

            return(response);
        }
        public virtual async Task <UpdateResponse <ApiPipelineStepStatuResponseModel> > Update(
            int id,
            ApiPipelineStepStatuRequestModel model)
        {
            var validationResult = await this.PipelineStepStatuModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                var bo = this.BolPipelineStepStatuMapper.MapModelToBO(id, model);
                await this.PipelineStepStatuRepository.Update(this.DalPipelineStepStatuMapper.MapBOToEF(bo));

                var record = await this.PipelineStepStatuRepository.Get(id);

                return(new UpdateResponse <ApiPipelineStepStatuResponseModel>(this.BolPipelineStepStatuMapper.MapBOToModel(this.DalPipelineStepStatuMapper.MapEFToBO(record))));
            }
            else
            {
                return(new UpdateResponse <ApiPipelineStepStatuResponseModel>(validationResult));
            }
        }
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IPipelineStepStatuRepository>();
            var model = new ApiPipelineStepStatuRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <PipelineStepStatu>())).Returns(Task.FromResult(new PipelineStepStatu()));
            var service = new PipelineStepStatuService(mock.LoggerMock.Object,
                                                       mock.RepositoryMock.Object,
                                                       mock.ModelValidatorMockFactory.PipelineStepStatuModelValidatorMock.Object,
                                                       mock.BOLMapperMockFactory.BOLPipelineStepStatuMapperMock,
                                                       mock.DALMapperMockFactory.DALPipelineStepStatuMapperMock,
                                                       mock.BOLMapperMockFactory.BOLPipelineStepMapperMock,
                                                       mock.DALMapperMockFactory.DALPipelineStepMapperMock);

            CreateResponse <ApiPipelineStepStatuResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.PipelineStepStatuModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiPipelineStepStatuRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <PipelineStepStatu>()));
        }
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <IPipelineStepStatuRepository>();
            var model = new ApiPipelineStepStatuRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new PipelineStepStatuService(mock.LoggerMock.Object,
                                                       mock.RepositoryMock.Object,
                                                       mock.ModelValidatorMockFactory.PipelineStepStatuModelValidatorMock.Object,
                                                       mock.BOLMapperMockFactory.BOLPipelineStepStatuMapperMock,
                                                       mock.DALMapperMockFactory.DALPipelineStepStatuMapperMock,
                                                       mock.BOLMapperMockFactory.BOLPipelineStepMapperMock,
                                                       mock.DALMapperMockFactory.DALPipelineStepMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.PipelineStepStatuModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
        }
Example #13
0
        public virtual async Task <IActionResult> Update(int id, [FromBody] ApiPipelineStepStatuRequestModel model)
        {
            ApiPipelineStepStatuRequestModel request = await this.PatchModel(id, this.PipelineStepStatuModelMapper.CreatePatch(model));

            if (request == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                UpdateResponse <ApiPipelineStepStatuResponseModel> result = await this.PipelineStepStatuService.Update(id, request);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
Example #14
0
        public virtual async Task <IActionResult> Patch(int id, [FromBody] JsonPatchDocument <ApiPipelineStepStatuRequestModel> patch)
        {
            ApiPipelineStepStatuResponseModel record = await this.PipelineStepStatuService.Get(id);

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

                UpdateResponse <ApiPipelineStepStatuResponseModel> result = await this.PipelineStepStatuService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
 public async Task <ValidationResult> ValidateUpdateAsync(int id, ApiPipelineStepStatuRequestModel model)
 {
     this.NameRules();
     return(await this.ValidateAsync(model, id));
 }