public virtual ApiProductProductPhotoResponseModel MapBOToModel(
            BOProductProductPhoto boProductProductPhoto)
        {
            var model = new ApiProductProductPhotoResponseModel();

            model.SetProperties(boProductProductPhoto.ProductID, boProductProductPhoto.ModifiedDate, boProductProductPhoto.Primary, boProductProductPhoto.ProductPhotoID);

            return(model);
        }
Ejemplo n.º 2
0
        public async void TestGet()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());
            ApiProductProductPhotoResponseModel response = await client.ProductProductPhotoGetAsync(1);

            response.Should().NotBeNull();
        }
        public void MapResponseToRequest()
        {
            var mapper = new ApiProductProductPhotoModelMapper();
            var model  = new ApiProductProductPhotoResponseModel();

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

            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Primary.Should().Be(true);
            response.ProductPhotoID.Should().Be(1);
        }
Ejemplo n.º 4
0
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiProductProductPhotoResponseModel response = await this.ProductProductPhotoService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
Ejemplo n.º 5
0
        public void MapBOToModel()
        {
            var mapper = new BOLProductProductPhotoMapper();
            BOProductProductPhoto bo = new BOProductProductPhoto();

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

            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Primary.Should().Be(true);
            response.ProductID.Should().Be(1);
            response.ProductPhotoID.Should().Be(1);
        }
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IProductProductPhotoRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ProductProductPhoto>(null));
            var service = new ProductProductPhotoService(mock.LoggerMock.Object,
                                                         mock.RepositoryMock.Object,
                                                         mock.ModelValidatorMockFactory.ProductProductPhotoModelValidatorMock.Object,
                                                         mock.BOLMapperMockFactory.BOLProductProductPhotoMapperMock,
                                                         mock.DALMapperMockFactory.DALProductProductPhotoMapperMock);

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

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Ejemplo n.º 7
0
        public async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            ApiProductProductPhotoResponseModel model = await client.ProductProductPhotoGetAsync(1);

            ApiProductProductPhotoModelMapper mapper = new ApiProductProductPhotoModelMapper();

            UpdateResponse <ApiProductProductPhotoResponseModel> updateResponse = await client.ProductProductPhotoUpdateAsync(model.ProductID, mapper.MapResponseToRequest(model));

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
        }
Ejemplo n.º 8
0
        public async void Create_Errors()
        {
            ProductProductPhotoControllerMockFacade mock = new ProductProductPhotoControllerMockFacade();

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

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

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

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

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

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
Ejemplo n.º 10
0
        public virtual async Task <IActionResult> Patch(int id, [FromBody] JsonPatchDocument <ApiProductProductPhotoRequestModel> patch)
        {
            ApiProductProductPhotoResponseModel record = await this.ProductProductPhotoService.Get(id);

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

                UpdateResponse <ApiProductProductPhotoResponseModel> result = await this.ProductProductPhotoService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
        public async void TestGet()
        {
            ApiProductProductPhotoResponseModel response = await this.Client.ProductProductPhotoGetAsync(1);

            response.Should().NotBeNull();
        }