public void CreatePatch()
        {
            var mapper = new ApiDeploymentHistoryModelMapper();
            var model  = new ApiDeploymentHistoryRequestModel();

            model.SetProperties("A", "A", DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), "A", "A", 1, "A", "A", "A", "A", "A", DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), "A", "A", DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), "A", "A", "A", "A");

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

            patch.ApplyTo(response);
            response.ChannelId.Should().Be("A");
            response.ChannelName.Should().Be("A");
            response.CompletedTime.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.Created.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.DeployedBy.Should().Be("A");
            response.DeploymentName.Should().Be("A");
            response.DurationSeconds.Should().Be(1);
            response.EnvironmentId.Should().Be("A");
            response.EnvironmentName.Should().Be("A");
            response.ProjectId.Should().Be("A");
            response.ProjectName.Should().Be("A");
            response.ProjectSlug.Should().Be("A");
            response.QueueTime.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.ReleaseId.Should().Be("A");
            response.ReleaseVersion.Should().Be("A");
            response.StartTime.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.TaskId.Should().Be("A");
            response.TaskState.Should().Be("A");
            response.TenantId.Should().Be("A");
            response.TenantName.Should().Be("A");
        }
        public void MapModelToBO()
        {
            var mapper = new BOLDeploymentHistoryMapper();
            ApiDeploymentHistoryRequestModel model = new ApiDeploymentHistoryRequestModel();

            model.SetProperties("A", "A", DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), "A", "A", 1, "A", "A", "A", "A", "A", DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), "A", "A", DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), "A", "A", "A", "A");
            BODeploymentHistory response = mapper.MapModelToBO("A", model);

            response.ChannelId.Should().Be("A");
            response.ChannelName.Should().Be("A");
            response.CompletedTime.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.Created.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.DeployedBy.Should().Be("A");
            response.DeploymentName.Should().Be("A");
            response.DurationSeconds.Should().Be(1);
            response.EnvironmentId.Should().Be("A");
            response.EnvironmentName.Should().Be("A");
            response.ProjectId.Should().Be("A");
            response.ProjectName.Should().Be("A");
            response.ProjectSlug.Should().Be("A");
            response.QueueTime.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.ReleaseId.Should().Be("A");
            response.ReleaseVersion.Should().Be("A");
            response.StartTime.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.TaskId.Should().Be("A");
            response.TaskState.Should().Be("A");
            response.TenantId.Should().Be("A");
            response.TenantName.Should().Be("A");
        }
        public virtual BODeploymentHistory MapModelToBO(
            string deploymentId,
            ApiDeploymentHistoryRequestModel model
            )
        {
            BODeploymentHistory boDeploymentHistory = new BODeploymentHistory();

            boDeploymentHistory.SetProperties(
                deploymentId,
                model.ChannelId,
                model.ChannelName,
                model.CompletedTime,
                model.Created,
                model.DeployedBy,
                model.DeploymentName,
                model.DurationSeconds,
                model.EnvironmentId,
                model.EnvironmentName,
                model.ProjectId,
                model.ProjectName,
                model.ProjectSlug,
                model.QueueTime,
                model.ReleaseId,
                model.ReleaseVersion,
                model.StartTime,
                model.TaskId,
                model.TaskState,
                model.TenantId,
                model.TenantName);
            return(boDeploymentHistory);
        }
        private async Task <ApiDeploymentHistoryResponseModel> CreateRecord()
        {
            var model = new ApiDeploymentHistoryRequestModel();

            model.SetProperties("B", "B", DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), "B", "B", 2, "B", "B", "B", "B", "B", DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), "B", "B", DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), "B", "B", "B", "B");
            CreateResponse <ApiDeploymentHistoryResponseModel> result = await this.Client.DeploymentHistoryCreateAsync(model);

            result.Success.Should().BeTrue();
            return(result.Record);
        }
Exemple #5
0
        public virtual async Task <IActionResult> Create([FromBody] ApiDeploymentHistoryRequestModel model)
        {
            CreateResponse <ApiDeploymentHistoryResponseModel> result = await this.DeploymentHistoryService.Create(model);

            if (result.Success)
            {
                return(this.Created($"{this.Settings.ExternalBaseUrl}/api/DeploymentHistories/{result.Record.DeploymentId}", result));
            }
            else
            {
                return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
            }
        }
        public virtual async Task <CreateResponse <ApiDeploymentHistoryResponseModel> > Create(
            ApiDeploymentHistoryRequestModel model)
        {
            CreateResponse <ApiDeploymentHistoryResponseModel> response = new CreateResponse <ApiDeploymentHistoryResponseModel>(await this.deploymentHistoryModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                var bo     = this.bolDeploymentHistoryMapper.MapModelToBO(default(string), model);
                var record = await this.deploymentHistoryRepository.Create(this.dalDeploymentHistoryMapper.MapBOToEF(bo));

                response.SetRecord(this.bolDeploymentHistoryMapper.MapBOToModel(this.dalDeploymentHistoryMapper.MapEFToBO(record)));
            }

            return(response);
        }
Exemple #7
0
        private async Task <ApiDeploymentHistoryRequestModel> PatchModel(string id, JsonPatchDocument <ApiDeploymentHistoryRequestModel> patch)
        {
            var record = await this.DeploymentHistoryService.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                ApiDeploymentHistoryRequestModel request = this.DeploymentHistoryModelMapper.MapResponseToRequest(record);
                patch.ApplyTo(request);
                return(request);
            }
        }
Exemple #8
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IDeploymentHistoryRepository>();
            var model = new ApiDeploymentHistoryRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <DeploymentHistory>())).Returns(Task.FromResult(new DeploymentHistory()));
            var service = new DeploymentHistoryService(mock.LoggerMock.Object,
                                                       mock.RepositoryMock.Object,
                                                       mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Object,
                                                       mock.BOLMapperMockFactory.BOLDeploymentHistoryMapperMock,
                                                       mock.DALMapperMockFactory.DALDeploymentHistoryMapperMock);

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

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiDeploymentHistoryRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <DeploymentHistory>()));
        }
Exemple #9
0
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <IDeploymentHistoryRepository>();
            var model = new ApiDeploymentHistoryRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <string>())).Returns(Task.CompletedTask);
            var service = new DeploymentHistoryService(mock.LoggerMock.Object,
                                                       mock.RepositoryMock.Object,
                                                       mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Object,
                                                       mock.BOLMapperMockFactory.BOLDeploymentHistoryMapperMock,
                                                       mock.DALMapperMockFactory.DALDeploymentHistoryMapperMock);

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

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <string>()));
            mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <string>()));
        }
        public virtual async Task <UpdateResponse <ApiDeploymentHistoryResponseModel> > Update(
            string deploymentId,
            ApiDeploymentHistoryRequestModel model)
        {
            var validationResult = await this.deploymentHistoryModelValidator.ValidateUpdateAsync(deploymentId, model);

            if (validationResult.IsValid)
            {
                var bo = this.bolDeploymentHistoryMapper.MapModelToBO(deploymentId, model);
                await this.deploymentHistoryRepository.Update(this.dalDeploymentHistoryMapper.MapBOToEF(bo));

                var record = await this.deploymentHistoryRepository.Get(deploymentId);

                return(new UpdateResponse <ApiDeploymentHistoryResponseModel>(this.bolDeploymentHistoryMapper.MapBOToModel(this.dalDeploymentHistoryMapper.MapEFToBO(record))));
            }
            else
            {
                return(new UpdateResponse <ApiDeploymentHistoryResponseModel>(validationResult));
            }
        }
Exemple #11
0
        public virtual async Task <IActionResult> Update(string id, [FromBody] ApiDeploymentHistoryRequestModel model)
        {
            ApiDeploymentHistoryRequestModel request = await this.PatchModel(id, this.DeploymentHistoryModelMapper.CreatePatch(model));

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

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
Exemple #12
0
 public async Task <ValidationResult> ValidateUpdateAsync(string id, ApiDeploymentHistoryRequestModel model)
 {
     this.ChannelIdRules();
     this.ChannelNameRules();
     this.CompletedTimeRules();
     this.CreatedRules();
     this.DeployedByRules();
     this.DeploymentNameRules();
     this.DurationSecondsRules();
     this.EnvironmentIdRules();
     this.EnvironmentNameRules();
     this.ProjectIdRules();
     this.ProjectNameRules();
     this.ProjectSlugRules();
     this.QueueTimeRules();
     this.ReleaseIdRules();
     this.ReleaseVersionRules();
     this.StartTimeRules();
     this.TaskIdRules();
     this.TaskStateRules();
     this.TenantIdRules();
     this.TenantNameRules();
     return(await this.ValidateAsync(model, id));
 }
Exemple #13
0
        public virtual async Task <IActionResult> Patch(string id, [FromBody] JsonPatchDocument <ApiDeploymentHistoryRequestModel> patch)
        {
            ApiDeploymentHistoryResponseModel record = await this.DeploymentHistoryService.Get(id);

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

                UpdateResponse <ApiDeploymentHistoryResponseModel> result = await this.DeploymentHistoryService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }