示例#1
0
        public void Create_Test_ProductOptionsRepositoryCreateShouldBeCalled()
        {
            var guid = new Guid();

            _productOptionsRepositoryMock.Setup(m => m.Create(It.IsAny <ProductOption>()));

            _underTest.Create(guid, new ProductOption());

            _productOptionsRepositoryMock.Verify(m => m.Create(It.IsAny <ProductOption>()), Times.Once);
        }
        public HttpResponseMessage CreateOption(Guid productId, ProductOption option)
        {
            try
            {
                if (_optionService.Create(productId, option))
                {
                    return(Request.CreateResponse(HttpStatusCode.Created));
                }

                return(Request.CreateResponse(HttpStatusCode.NotModified, $"Product with Product ID '{productId}' and Option ID '{option.Id}' already exist"));
            }
            catch (Exception e)
            {
                return(Request.Error(e.Message));
            }
        }