public virtual ApiLibraryVariableSetResponseModel MapBOToModel(
            BOLibraryVariableSet boLibraryVariableSet)
        {
            var model = new ApiLibraryVariableSetResponseModel();

            model.SetProperties(boLibraryVariableSet.Id, boLibraryVariableSet.ContentType, boLibraryVariableSet.JSON, boLibraryVariableSet.Name, boLibraryVariableSet.VariableSetId);

            return(model);
        }
Ejemplo n.º 2
0
        public void MapResponseToRequest()
        {
            var mapper = new ApiLibraryVariableSetModelMapper();
            var model  = new ApiLibraryVariableSetResponseModel();

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

            response.ContentType.Should().Be("A");
            response.JSON.Should().Be("A");
            response.Name.Should().Be("A");
            response.VariableSetId.Should().Be("A");
        }
        public async virtual Task <IActionResult> Get(string id)
        {
            ApiLibraryVariableSetResponseModel response = await this.LibraryVariableSetService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
        public void MapBOToModel()
        {
            var mapper = new BOLLibraryVariableSetMapper();
            BOLibraryVariableSet bo = new BOLibraryVariableSet();

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

            response.ContentType.Should().Be("A");
            response.Id.Should().Be("A");
            response.JSON.Should().Be("A");
            response.Name.Should().Be("A");
            response.VariableSetId.Should().Be("A");
        }
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <ILibraryVariableSetRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <LibraryVariableSet>(null));
            var service = new LibraryVariableSetService(mock.LoggerMock.Object,
                                                        mock.RepositoryMock.Object,
                                                        mock.ModelValidatorMockFactory.LibraryVariableSetModelValidatorMock.Object,
                                                        mock.BOLMapperMockFactory.BOLLibraryVariableSetMapperMock,
                                                        mock.DALMapperMockFactory.DALLibraryVariableSetMapperMock);

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

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>()));
        }
Ejemplo n.º 6
0
        public async void Create_Errors()
        {
            LibraryVariableSetControllerMockFacade mock = new LibraryVariableSetControllerMockFacade();

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

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

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

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiLibraryVariableSetRequestModel>()));
        }
Ejemplo n.º 7
0
        public async void All_Exists()
        {
            LibraryVariableSetControllerMockFacade mock = new LibraryVariableSetControllerMockFacade();
            var record  = new ApiLibraryVariableSetResponseModel();
            var records = new List <ApiLibraryVariableSetResponseModel>();

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

            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 <ApiLibraryVariableSetRequestModel> patch)
        {
            ApiLibraryVariableSetResponseModel record = await this.LibraryVariableSetService.Get(id);

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

                UpdateResponse <ApiLibraryVariableSetResponseModel> result = await this.LibraryVariableSetService.Update(id, model);

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

            response.Should().NotBeNull();
        }