public virtual ApiProductModelIllustrationResponseModel MapBOToModel(
            BOProductModelIllustration boProductModelIllustration)
        {
            var model = new ApiProductModelIllustrationResponseModel();

            model.SetProperties(boProductModelIllustration.ProductModelID, boProductModelIllustration.IllustrationID, boProductModelIllustration.ModifiedDate);

            return(model);
        }
Esempio n. 2
0
        public void MapResponseToRequest()
        {
            var mapper = new ApiProductModelIllustrationModelMapper();
            var model  = new ApiProductModelIllustrationResponseModel();

            model.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"));
            ApiProductModelIllustrationRequestModel response = mapper.MapResponseToRequest(model);

            response.IllustrationID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
        }
        public void MapBOToModel()
        {
            var mapper = new BOLProductModelIllustrationMapper();
            BOProductModelIllustration bo = new BOProductModelIllustration();

            bo.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"));
            ApiProductModelIllustrationResponseModel response = mapper.MapBOToModel(bo);

            response.IllustrationID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ProductModelID.Should().Be(1);
        }
Esempio n. 4
0
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiProductModelIllustrationResponseModel response = await this.ProductModelIllustrationService.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 <IProductModelIllustrationRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ProductModelIllustration>(null));
            var service = new ProductModelIllustrationService(mock.LoggerMock.Object,
                                                              mock.RepositoryMock.Object,
                                                              mock.ModelValidatorMockFactory.ProductModelIllustrationModelValidatorMock.Object,
                                                              mock.BOLMapperMockFactory.BOLProductModelIllustrationMapperMock,
                                                              mock.DALMapperMockFactory.DALProductModelIllustrationMapperMock);

            ApiProductModelIllustrationResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Esempio n. 6
0
        public async void Create_Errors()
        {
            ProductModelIllustrationControllerMockFacade mock = new ProductModelIllustrationControllerMockFacade();

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

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

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

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

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

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
Esempio n. 8
0
        public virtual async Task <IActionResult> Patch(int id, [FromBody] JsonPatchDocument <ApiProductModelIllustrationRequestModel> patch)
        {
            ApiProductModelIllustrationResponseModel record = await this.ProductModelIllustrationService.Get(id);

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

                UpdateResponse <ApiProductModelIllustrationResponseModel> result = await this.ProductModelIllustrationService.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()
        {
            ApiProductModelIllustrationResponseModel response = await this.Client.ProductModelIllustrationGetAsync(1);

            response.Should().NotBeNull();
        }