public async Task PutsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ProductsClient(connection);

                var customFields = new Dictionary <string, ICustomField>()
                {
                    { "5913c8efdcf5c641a516d1fbd498235544b1b195", new IntCustomField(123) }
                };
                var editProduct = new ProductUpdate {
                    Name = "new product name", CustomFields = customFields
                };
                await client.Edit(123, editProduct);

                Received.InOrder(async() =>
                {
                    await connection.Put <UpdatedProduct>(Arg.Is <Uri>(u => u.ToString() == "products/123"),
                                                          Arg.Is <ProductUpdate>(d => d.Name == "new product name" && d.CustomFields == customFields));
                });
            }
        public ActionResult Edit(ProductViewModel CVM, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                ProductsClient CC = new ProductsClient();
                if (file == null)
                {
                    CVM.product.Pictures = CC.find(CVM.product.Product_ID).Pictures;
                }
                else
                {
                    string ImageName    = Path.GetFileName(file.FileName);
                    string physicalPath = Server.MapPath("~/Product_Images/" + ImageName);

                    // save image in folder
                    file.SaveAs(physicalPath);
                    CVM.product.Pictures = ImageName;
                }
                int Storeid = CC.Storeid(Convert.ToInt32(Session["userID"]));
                CVM.product.Store_ID = Storeid;
                CC.Edit(CVM.product);
            }
            return(RedirectToAction("Index"));
        }
            public async Task EnsuresNonNullArguments()
            {
                var client = new ProductsClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit(1, null));
            }