public virtual ApiDeploymentResponseModel MapBOToModel( BODeployment boDeployment) { var model = new ApiDeploymentResponseModel(); model.SetProperties(boDeployment.Id, boDeployment.ChannelId, boDeployment.Created, boDeployment.DeployedBy, boDeployment.DeployedToMachineIds, boDeployment.EnvironmentId, boDeployment.JSON, boDeployment.Name, boDeployment.ProjectGroupId, boDeployment.ProjectId, boDeployment.ReleaseId, boDeployment.TaskId, boDeployment.TenantId); return(model); }
public async virtual Task <IActionResult> Get(string id) { ApiDeploymentResponseModel response = await this.DeploymentService.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 <IDeploymentRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <Deployment>(null)); var service = new DeploymentService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeploymentModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDeploymentMapperMock, mock.DALMapperMockFactory.DALDeploymentMapperMock, mock.BOLMapperMockFactory.BOLDeploymentRelatedMachineMapperMock, mock.DALMapperMockFactory.DALDeploymentRelatedMachineMapperMock); ApiDeploymentResponseModel response = await service.Get(default(string)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>())); }
public async void Create_Errors() { DeploymentControllerMockFacade mock = new DeploymentControllerMockFacade(); var mockResponse = new Mock <CreateResponse <ApiDeploymentResponseModel> >(new FluentValidation.Results.ValidationResult()); var mockRecord = new ApiDeploymentResponseModel(); mockResponse.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiDeploymentRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiDeploymentResponseModel> >(mockResponse.Object)); DeploymentController controller = new DeploymentController(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 ApiDeploymentRequestModel()); response.Should().BeOfType <ObjectResult>(); (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiDeploymentRequestModel>())); }
public void MapResponseToRequest() { var mapper = new ApiDeploymentModelMapper(); var model = new ApiDeploymentResponseModel(); model.SetProperties("A", "A", DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), "A", "A", "A", "A", "A", "A", "A", "A", "A", "A"); ApiDeploymentRequestModel response = mapper.MapResponseToRequest(model); response.ChannelId.Should().Be("A"); response.Created.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM")); response.DeployedBy.Should().Be("A"); response.DeployedToMachineIds.Should().Be("A"); response.EnvironmentId.Should().Be("A"); response.JSON.Should().Be("A"); response.Name.Should().Be("A"); response.ProjectGroupId.Should().Be("A"); response.ProjectId.Should().Be("A"); response.ReleaseId.Should().Be("A"); response.TaskId.Should().Be("A"); response.TenantId.Should().Be("A"); }
public async void All_Exists() { DeploymentControllerMockFacade mock = new DeploymentControllerMockFacade(); var record = new ApiDeploymentResponseModel(); var records = new List <ApiDeploymentResponseModel>(); records.Add(record); mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records)); DeploymentController controller = new DeploymentController(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 <ApiDeploymentResponseModel>; items.Count.Should().Be(1); mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>())); }
public void MapBOToModel() { var mapper = new BOLDeploymentMapper(); BODeployment bo = new BODeployment(); bo.SetProperties("A", "A", DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), "A", "A", "A", "A", "A", "A", "A", "A", "A", "A"); ApiDeploymentResponseModel response = mapper.MapBOToModel(bo); response.ChannelId.Should().Be("A"); response.Created.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM")); response.DeployedBy.Should().Be("A"); response.DeployedToMachineIds.Should().Be("A"); response.EnvironmentId.Should().Be("A"); response.Id.Should().Be("A"); response.JSON.Should().Be("A"); response.Name.Should().Be("A"); response.ProjectGroupId.Should().Be("A"); response.ProjectId.Should().Be("A"); response.ReleaseId.Should().Be("A"); response.TaskId.Should().Be("A"); response.TenantId.Should().Be("A"); }
public virtual async Task <IActionResult> Patch(string id, [FromBody] JsonPatchDocument <ApiDeploymentRequestModel> patch) { ApiDeploymentResponseModel record = await this.DeploymentService.Get(id); if (record == null) { return(this.StatusCode(StatusCodes.Status404NotFound)); } else { ApiDeploymentRequestModel model = await this.PatchModel(id, patch); UpdateResponse <ApiDeploymentResponseModel> result = await this.DeploymentService.Update(id, model); if (result.Success) { return(this.Ok(result)); } else { return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result)); } } }
public async void TestGet() { ApiDeploymentResponseModel response = await this.Client.DeploymentGetAsync("A"); response.Should().NotBeNull(); }