public void MapResponseToRequest()
        {
            var mapper = new ApiDeploymentHistoryModelMapper();
            var model  = new ApiDeploymentHistoryResponseModel();

            model.SetProperties("A", "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");
            ApiDeploymentHistoryRequestModel response = mapper.MapResponseToRequest(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 ApiDeploymentHistoryResponseModel MapBOToModel(
            BODeploymentHistory boDeploymentHistory)
        {
            var model = new ApiDeploymentHistoryResponseModel();

            model.SetProperties(boDeploymentHistory.DeploymentId, boDeploymentHistory.ChannelId, boDeploymentHistory.ChannelName, boDeploymentHistory.CompletedTime, boDeploymentHistory.Created, boDeploymentHistory.DeployedBy, boDeploymentHistory.DeploymentName, boDeploymentHistory.DurationSeconds, boDeploymentHistory.EnvironmentId, boDeploymentHistory.EnvironmentName, boDeploymentHistory.ProjectId, boDeploymentHistory.ProjectName, boDeploymentHistory.ProjectSlug, boDeploymentHistory.QueueTime, boDeploymentHistory.ReleaseId, boDeploymentHistory.ReleaseVersion, boDeploymentHistory.StartTime, boDeploymentHistory.TaskId, boDeploymentHistory.TaskState, boDeploymentHistory.TenantId, boDeploymentHistory.TenantName);

            return(model);
        }
Example #3
0
        public async virtual Task <IActionResult> Get(string id)
        {
            ApiDeploymentHistoryResponseModel response = await this.DeploymentHistoryService.Get(id);

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

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

            ApiDeploymentHistoryResponseModel response = await service.Get(default(string));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>()));
        }
        public async void Create_Errors()
        {
            DeploymentHistoryControllerMockFacade mock = new DeploymentHistoryControllerMockFacade();

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

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

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

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiDeploymentHistoryRequestModel>()));
        }
        public async void All_Exists()
        {
            DeploymentHistoryControllerMockFacade mock = new DeploymentHistoryControllerMockFacade();
            var record  = new ApiDeploymentHistoryResponseModel();
            var records = new List <ApiDeploymentHistoryResponseModel>();

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

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
Example #7
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));
                }
            }
        }
        public async void TestGet()
        {
            ApiDeploymentHistoryResponseModel response = await this.Client.DeploymentHistoryGetAsync("A");

            response.Should().NotBeNull();
        }