public bool AddProduct(string pCodigo, string pName, string pValue, bool pDiscount, string pVDisconunt)
        {
            DataArtcilesJson pResultArticle = new DataArtcilesJson();

            pResultArticle.id         = pCodigo;
            pResultArticle.name       = pName;
            pResultArticle.price      = pValue;
            pResultArticle.idDiscount = pVDisconunt;

            var client = new HttpClient()
            {
                BaseAddress = new Uri("http://localhost:52046/api/articles")
            };

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage response;
            var content = new StringContent(JsonConvert.SerializeObject(pResultArticle).ToString(),
                                            Encoding.UTF8, "application/json");

            response = client.PostAsync(client.BaseAddress, content).Result;
            if (response.IsSuccessStatusCode)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public DataArtcilesJson SearchProduct(string pCodigo)
        {
            DataArtcilesJson pResultArticle = new DataArtcilesJson();

            pResultArticle.id = pCodigo;

            var client = new HttpClient()
            {
                BaseAddress = new Uri("http://localhost:52046/api/articles/" + pResultArticle.id)
            };

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response;

            response = client.GetAsync(client.BaseAddress).Result;
            if (response.IsSuccessStatusCode)
            {
                var    responseContent = response.Content;
                string responseString  = responseContent.ReadAsStringAsync().Result;
                return(JsonConvert.DeserializeObject <DataArtcilesJson>(responseString));
            }
            else
            {
                pResultArticle = null;
                return(pResultArticle);
            }
        }
        public void TestMethodAddDiscountInProduct()
        {
            string            codP             = "2";
            string            codD             = "1";
            DataArtcilesJson  dataArtcilesJson = SearchProduct(codP);
            DataDiscountsJson dataDiscounts    = SearchDiscount(codD);

            dataArtcilesJson.idDiscount = dataDiscounts.id_discount;

            Assert.AreEqual(dataArtcilesJson.idDiscount, dataDiscounts.id_discount);
        }
        public void TestMethodAddProductInCart()
        {
            string codP = "2";
            List <DataArtcilesItensJson> ldataArtc         = new List <DataArtcilesItensJson>();
            DataArtcilesJson             gDataArtcilesJson = SearchProduct(codP);
            string qProd = "10";
            DataArtcilesItensJson gDataArtcilesItensJson = new DataArtcilesItensJson();

            gDataArtcilesItensJson.id_article  = gDataArtcilesJson.id;
            gDataArtcilesItensJson.id_discount = gDataArtcilesJson.idDiscount;
            gDataArtcilesItensJson.quant       = qProd;
            ldataArtc.Add(gDataArtcilesItensJson);
            Assert.IsNotNull(AddCart(ldataArtc));
        }