diff --git a/include/faker-cxx/Commerce.h b/include/faker-cxx/Commerce.h index c95995af2..b0f861292 100644 --- a/include/faker-cxx/Commerce.h +++ b/include/faker-cxx/Commerce.h @@ -163,6 +163,49 @@ class Commerce */ static std::string paymentProvider(); + /** + * @brief Returns a random product description. + * + * @returns productDescription. + * + * @code + * Commerce::productDescription() // "Elevate your lifestyle with premium quality product." + * @endcode + */ + static std::string productDescription(); + + /** + * @brief Returns a random product category. + * + * @returns productCategory. + * + * @code + * Commerce::productCategory() // "Electronics" + * @endcode + */ + static std::string productCategory(); + + /** + * @brief Returns a random product review. + * + * @returns productReview. + * + * @code + * Commerce::productReview() // "Unfortunately, it broke shortly after I started using it." + * @endcode + */ + static std::string productReview(); + + /** + * @brief Returns a random product rating (0-5). + * + * @returns productRating. + * + * @code + * Commerce::productRating() // 4.1 + * @endcode + */ + static double productRating(); }; } diff --git a/src/modules/commerce/Commerce.cpp b/src/modules/commerce/Commerce.cpp index d49e8711c..43bf7de12 100644 --- a/src/modules/commerce/Commerce.cpp +++ b/src/modules/commerce/Commerce.cpp @@ -164,4 +164,22 @@ std::string Commerce::paymentProvider() { return Helper::arrayElement(paymentProviders); } + +std::string Commerce::productDescription() { + return Helper::arrayElement(productDescriptions); +} + +std::string Commerce::productCategory() +{ + return Helper::arrayElement(productCategoryNames); +} + +std::string Commerce::productReview() { + return Helper::arrayElement(productReviews); +} + +double Commerce::productRating() { + return Number::decimal(5.); +} + } diff --git a/src/modules/commerce/CommerceTest.cpp b/src/modules/commerce/CommerceTest.cpp index 87f47b8a5..df19453e1 100644 --- a/src/modules/commerce/CommerceTest.cpp +++ b/src/modules/commerce/CommerceTest.cpp @@ -225,3 +225,34 @@ TEST_F(CommerceTest, shouldGeneratePaymentProvider) ASSERT_TRUE(std::ranges::any_of(paymentProviders, [generatedPaymentProvider](const std::string& paymentProvider) { return paymentProvider == generatedPaymentProvider; })); } + +TEST_F(CommerceTest, shouldGenerateProductDescription) +{ + const auto generatedProductDescription = Commerce::productDescription(); + + ASSERT_TRUE(std::ranges::any_of(productDescriptions, [generatedProductDescription](const std::string& productDescription) + { return productDescription == generatedProductDescription; })); +} + +TEST_F(CommerceTest, shouldGenerateProductCategory) +{ + const auto generatedProductCategory = Commerce::productCategory(); + + ASSERT_TRUE(std::ranges::any_of(productCategoryNames, [generatedProductCategory](const std::string& productCategory) + { return productCategory == generatedProductCategory; })); +} + +TEST_F(CommerceTest, shouldGenerateProductReview) +{ + const auto generatedProductReview = Commerce::productReview(); + + ASSERT_TRUE(std::ranges::any_of(productReviews, [generatedProductReview](const std::string& productReview) + { return productReview == generatedProductReview; })); +} + +TEST_F(CommerceTest, shouldGenerateProductRating) +{ + const auto generatedProductRating = Commerce::productRating(); + + ASSERT_TRUE(0. <= generatedProductRating && generatedProductRating <= 5.); +} diff --git a/src/modules/commerce/data/Commerce.h b/src/modules/commerce/data/Commerce.h index b410ba20c..24964a7cb 100644 --- a/src/modules/commerce/data/Commerce.h +++ b/src/modules/commerce/data/Commerce.h @@ -27,4 +27,59 @@ const std::vector paymentTypes = {"Credit Card", "Debit Card", "Cas const std::vector paymentProviders = {"Stripe", "Paypal", "Square", "Helcim", "Merchant One", "Flagship Merchant Services", "Stax"}; + +const std::vector productDescriptions = { + "Experience convenience and efficiency with innovative solution.", + "Elevate your lifestyle with premium quality product.", + "Unlock endless possibilities with versatile tool, offering flexibility and adaptability,", + "Enhance your performance with cutting-edge technology.", + "Discover the perfect balance of style and functionality with sleek design.", + "Embrace comfort and luxury with indulgent product.", + "Achieve peace of mind with reliable solution, providing stability and assurance in every use.", + "Ignite your creativity with versatile accessory.", + "Experience the difference with high-performance product, engineered for superior quality.", + "Simplify your life with user-friendly solution, designed with intuitive features .", + "Upgrade your everyday routine with essential product, adding convenience and efficiency to your tasks.", + "Stay connected and productive with innovative technology, keeping you in control and on top of your game.", + "Make a statement with stylish addition, adding a touch of elegance and sophistication to any setting.", + "Experience reliability like never before with dependable product, ensuring consistent performance day in and day out.", + "Unleash your potential with versatile tool, empowering you to tackle any challenge and achieve your goals.", + "Experience comfort redefined with ergonomic design, prioritizing your well-being and comfort in every use.", + "Optimize your efficiency with streamlined solution, eliminating unnecessary steps and maximizing productivity.", + "Experience durability and longevity with rugged construction, built to withstand the test of time and rigorous use." +}; + +const std::vector productCategoryNames = { + "Art and Craft", "Baby Products", "Beauty Products", + "Board Games and Puzzles", "Books and Stationery", "Clothing, Shoes, and Jewelry", + "Electronics", "Fitness Equipment", "Furniture and Furnishings", + "Health and Wellness", "Home Decor", "Kitchen Appliances", + "Musical Instruments", "Office Supplies", "Outdoor Gear", + "Pet Supplies", "Photography Equipment", "Sporting Goods", + "Tech Gadgets", "Toys" +}; + +const std::vector productReviews = { + "This product exceeded my expectations.", + "I'm thrilled with the quality of this purchase.", + "This product is worth every penny.", + "I'm impressed with how well it performs.", + "I've been using it for a while now, and it hasn't disappointed.", + "It's okay, but nothing special.", + "I'm on the fence about this product.", + "There are pros and cons to this purchase.", + "It's neither good nor bad, just average.", + "I have mixed feelings about this product.", + "It's decent, but there's room for improvement.", + "It meets my basic needs, but there are better options out there.", + "I would consider it if you're on a budget.", + "Not bad, but not great either.", + "It's acceptable, but I expected more for the price.", + "I was disappointed with the overall quality of this product.", + "Unfortunately, it broke shortly after I started using it.", + "I found it to be overpriced for what it offers.", + "It feels cheaply made and lacks durability.", + "It's difficult to operate and not user-friendly." +}; + }