public async Task <bool> Testfor_ValidateProductId()
        {
            //Arrange
            bool res = false;

            //Act
            adminservice.Setup(repo => repo.AddProduct(_product)).ReturnsAsync(_product);
            var result = await _adminGroceryS.AddProduct(_product);

            if (result.ProductId.Length.ToString() == _product.ProductId.Length.ToString())
            {
                res = true;
            }
            //Asert
            //final result displaying in text file
            await File.AppendAllTextAsync("../../../../output_boundary_revised.txt", "Testfor_ValidateProductId=" + res + "\n");

            return(res);
        }
Exemple #2
0
        public async Task <IActionResult> AddNewProduct([FromBody] ProductViewModel model)
        {
            //Do code here
            Product pro = new Product();

            pro.ProductName  = model.ProductName;
            pro.Description  = model.Description;
            pro.Amount       = model.Amount;
            pro.stock        = model.stock;
            pro.photo        = model.photo;
            pro.CatId        = model.CatId;
            pro.ProductOrder = model.ProductOrder;


            Task <Product> new_pro = _adminGS.AddProduct(pro);

            return(Created(HttpContext.Request.Scheme + "://" + HttpContext.Request.Host + HttpContext.Request.Path + "/" + pro.ProductId,
                           pro.ProductName));
            //return Ok();
        }
        public async Task <bool> Testfor_Validate_InvlidAddProduct()
        {
            //Arrange
            bool res = false;

            _product = null;
            //Act
            adminservice.Setup(repo => repo.AddProduct(_product)).ReturnsAsync(_product = null);
            var result = await _adminGroceryS.AddProduct(_product);

            if (result == null)
            {
                res = true;
            }
            //Asert
            //final result displaying in text file
            await File.AppendAllTextAsync("../../../../output_exception_revised.txt", "Testfor_Validate_InvlidAddProduct=" + res + "\n");

            return(res);
        }