public virtual ApiDashboardConfigurationResponseModel MapBOToModel(
            BODashboardConfiguration boDashboardConfiguration)
        {
            var model = new ApiDashboardConfigurationResponseModel();

            model.SetProperties(boDashboardConfiguration.Id, boDashboardConfiguration.IncludedEnvironmentIds, boDashboardConfiguration.IncludedProjectIds, boDashboardConfiguration.IncludedTenantIds, boDashboardConfiguration.IncludedTenantTags, boDashboardConfiguration.JSON);

            return(model);
        }
        public async virtual Task <IActionResult> Get(string id)
        {
            ApiDashboardConfigurationResponseModel response = await this.DashboardConfigurationService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
        public void MapResponseToRequest()
        {
            var mapper = new ApiDashboardConfigurationModelMapper();
            var model  = new ApiDashboardConfigurationResponseModel();

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

            response.IncludedEnvironmentIds.Should().Be("A");
            response.IncludedProjectIds.Should().Be("A");
            response.IncludedTenantIds.Should().Be("A");
            response.IncludedTenantTags.Should().Be("A");
            response.JSON.Should().Be("A");
        }
Esempio n. 4
0
        public void MapBOToModel()
        {
            var mapper = new BOLDashboardConfigurationMapper();
            BODashboardConfiguration bo = new BODashboardConfiguration();

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

            response.Id.Should().Be("A");
            response.IncludedEnvironmentIds.Should().Be("A");
            response.IncludedProjectIds.Should().Be("A");
            response.IncludedTenantIds.Should().Be("A");
            response.IncludedTenantTags.Should().Be("A");
            response.JSON.Should().Be("A");
        }
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IDashboardConfigurationRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <DashboardConfiguration>(null));
            var service = new DashboardConfigurationService(mock.LoggerMock.Object,
                                                            mock.RepositoryMock.Object,
                                                            mock.ModelValidatorMockFactory.DashboardConfigurationModelValidatorMock.Object,
                                                            mock.BOLMapperMockFactory.BOLDashboardConfigurationMapperMock,
                                                            mock.DALMapperMockFactory.DALDashboardConfigurationMapperMock);

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

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

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

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

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

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

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

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
        public virtual async Task <IActionResult> Patch(string id, [FromBody] JsonPatchDocument <ApiDashboardConfigurationRequestModel> patch)
        {
            ApiDashboardConfigurationResponseModel record = await this.DashboardConfigurationService.Get(id);

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

                UpdateResponse <ApiDashboardConfigurationResponseModel> result = await this.DashboardConfigurationService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
Esempio n. 9
0
        public async void TestGet()
        {
            ApiDashboardConfigurationResponseModel response = await this.Client.DashboardConfigurationGetAsync("A");

            response.Should().NotBeNull();
        }