Example #1
0
        public void AddToCart_AllParamsValid_Ok200()
        {
            //arrange
            int    expected = 200;
            CartIn cart     = new CartIn {
                idClient  = "14",
                idProduct = "563",
                quantity  = 2
            };

            //act
            int?actual = 0;

            try
            {
                var response = (OkObjectResult)cartServiceControllerMock.AddToCart(cart);
                actual = response.StatusCode;
            }
            catch (InvalidCastException e)
            {
                Console.WriteLine(e);
            }

            //assert
            Assert.AreEqual(expected, actual);
        }
Example #2
0
 public ActionResult AddToCart([FromBody] CartIn cartFromBody)
 {
     if (cache.AddToCart(cartFromBody.idClient, cartFromBody.idProduct, cartFromBody.quantity))
     {
         return(Ok("The product has been added to cart"));
     }
     else
     {
         return(Ok("product not added to cart"));
     }
     throw new NotImplementedException();
 }