예제 #1
0
 public HttpResponseMessage SaveProductFamily(ProductFamilyDto productFamilyResponseDto)
 {
     return(CreateHttpResponse(() =>
     {
         return Request.CreateResponse(_adminProcessor.SaveProductFamily(productFamilyResponseDto));
     }));
 }
예제 #2
0
        public void UpdateProductFamilyDetail_SuccessfullyWhenPriorityEqualandDirectionnotlessthenZero(int ID, string descriptionAdd)
        {
            var productFamilyDto = new ProductFamilyDto
            {
                Id          = ID,
                Description = descriptionAdd,
                Priority    = 2
            };


            var updatedProductFamily = new ProductFamily
            {
                ID          = ID,
                Description = descriptionAdd,
            };

            _productFamilyRepository.Find(productFamilyDto.Id).ReturnsForAnyArgs(LoadProductFamilyList().FirstOrDefault(x => x.ID == productFamilyDto.Id));

            _productFamilyRepository.GetAll().ReturnsForAnyArgs(LoadProductFamilyList());

            _productFamilyRepository.Update(Arg.Any <ProductFamily>()).Returns(updatedProductFamily);
            var actualResult = _adminProcessor.SaveProductFamily(productFamilyDto);

            Assert.AreEqual(updatedProductFamily.ID, actualResult.ID);
        }
예제 #3
0
        public void UpdateProductFamilyDetail_ProductFamilyNotFound(int ID, string descriptionAdd)
        {
            var productFamilyDto = new ProductFamilyDto
            {
                Id          = ID,
                Description = descriptionAdd,
            };

            _productFamilyRepository.Find(productFamilyDto.Id).ReturnsForAnyArgs(LoadProductFamilyList().FirstOrDefault(x => x.ID == productFamilyDto.Id));

            var actualResult = _adminProcessor.SaveProductFamily(productFamilyDto);

            _productFamilyRepository.Update(Arg.Any <ProductFamily>().DidNotReceive());
        }
예제 #4
0
        public void DeleteProductFamily_ProductFamilyNotFound(int ID, string userID)
        {
            var productFamilyDto = new ProductFamilyDto
            {
                Id = ID
            };

            _productFamilyRepository.
            GetSingle(x => x.ID == productFamilyDto.Id).
            ReturnsForAnyArgs(LoadProductFamilyList().FirstOrDefault(x => x.ID == productFamilyDto.Id));

            var actualResult = _adminProcessor.DeleteProductFamily(productFamilyDto.Id, userID);

            _productFamilyRepository.Update(Arg.Any <ProductFamily>().DidNotReceive());
        }
예제 #5
0
        public void AddProductFamilyDetail_Successfully(int ID, string descriptionAdd)
        {
            var productFamilyDto = new ProductFamilyDto
            {
                Id          = ID,
                Description = descriptionAdd,
            };

            var addedProductFamily = new ProductFamily
            {
                ID          = 1,
                Description = descriptionAdd
            };

            _productFamilyRepository.GetAll().ReturnsForAnyArgs(LoadProductFamilyList());

            _productFamilyRepository.Add(Arg.Any <ProductFamily>()).Returns(addedProductFamily);
            var actualResult = _adminProcessor.SaveProductFamily(productFamilyDto);

            Assert.AreEqual(addedProductFamily.ID, actualResult.ID);
        }
예제 #6
0
        public void DeleteProductFamily_Successfully(int ID, string userID)
        {
            var productFamilyDto = new ProductFamilyDto
            {
                Id = ID
            };


            var updatedProductFamily = new ProductFamily
            {
                ID     = ID,
                Active = false
            };

            _productFamilyRepository.
            GetSingle(x => x.ID == productFamilyDto.Id).
            ReturnsForAnyArgs(LoadProductFamilyList().FirstOrDefault(x => x.ID == productFamilyDto.Id));

            _productFamilyRepository.Update(Arg.Any <ProductFamily>()).Returns(updatedProductFamily);
            var actualResult = _adminProcessor.DeleteProductFamily(productFamilyDto.Id, userID);

            Assert.AreEqual(actualResult, true);
        }