Пример #1
0
        public void Success_DeleteByProductId()
        {
            int         index;
            string      result;
            UserProduct user_product;

            //Act
            index        = 59;
            user_product = new UserProduct
            {
                ProductId = products[index].Id,
                Username  = user.Username,
                IsActive  = false
            };

            result = db_userproduct.CreateUserProduct(user_product);

            if (result.Equals("Success"))
            {
                result = db_userproduct.DeleteByProductId(user_product.ProductId);
            }

            //Assert
            Assert.AreEqual("Success", result);
        }
        /// <summary>
        /// Deletes a user product.
        /// </summary>
        /// <param name="user_product"></param>
        /// <param name="instance_use"></param>
        /// <returns>string</returns>
        public string Delete(UserProduct user_product, string instance_use)
        {
            string result;

            switch (instance_use)
            {
            case "Username":
                result = db_userproduct.DeleteByUsername(user_product.Username);
                break;

            case "Product Id":
                result = db_userproduct.DeleteByProductId(user_product.ProductId);
                break;

            case "Both":
                result = db_userproduct.Delete(user_product);
                break;

            default:
                result = "The chosen instanse to use is invalid.";
                break;
            }

            return(result);
        }